I am trying to set RippleDrawable as the background of a list RippleDrawable . When using view.setBackgroundResource(R.drawable.ripple) everything works fine. Upon attempt
view.setBackground(view.getContext().getDrawable(R.drawable.ripple))
it works, but the ripple does not appear when the element is touched quickly (I also have an activated / checked state for the element), it appears only when I hold the view pressed.
The setBackgroundResource method in the View class is as follows:
if (resid != 0 && resid == mBackgroundResource) { return; } Drawable d = null; if (resid != 0) { d = mContext.getDrawable(resid); } setBackground(d); mBackgroundResource = resid;
so basically what i am trying to do manually.
NOTE. I want to use the setBackground method because I want to programmatically create a RippleDrawable.
Does anyone have an idea why this is happening?
source share