getResources().getDrawable(rippleResourceId, null) return rippleDrawable with the wrong color

111 Views Asked by At

I use android resourceId android.R.attr.actionBarItemBackground to set ripple.

On one item it works fine. On anther item I change the RippleDrawable radius, but then the ripple color changes to pink.

    int rippleResourceId = // android.R.attr.actionBarItemBackground from current context
    if (VERSION.SDK_INT >= VERSION_CODES.M) {
      RippleDrawable drawable =
          (RippleDrawable) getResources().getDrawable(rippleResourceId, null);
      drawable.setRadius(
          getContext()
              .getResources()
              .getDimensionPixelSize(R.dimen.ripple_radius));
 myFrameLayout.setBackground(drawable);
    } else {
       myFrameLayout.setBackgroundResource(discRippleResourceId);
    }

Anyhow had this problem?

1

There are 1 best solutions below

0
Elad Benda On BEST ANSWER

sending a null theme caused this difference

getDrawable(rippleResourceId, null);