@Override public void setBackgroundDrawable(Drawable background) { if (background instanceof RippleDrawable) { setRippleDrawable((RippleDrawable) background); return; } if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Background) { rippleDrawable.setCallback(null); rippleDrawable = null; } super.setBackgroundDrawable(background); }
@Override public void setRippleDrawable(RippleDrawable newRipple) { if (rippleDrawable != null) { rippleDrawable.setCallback(null); if (rippleDrawable.getStyle() == RippleDrawable.Style.Background) super.setBackgroundDrawable(rippleDrawable.getBackground()); } if (newRipple != null) { newRipple.setCallback(this); newRipple.setBounds(0, 0, getWidth(), getHeight()); newRipple.setState(getDrawableState()); ((Drawable) newRipple).setVisible(getVisibility() == VISIBLE, false); if (newRipple.getStyle() == RippleDrawable.Style.Background) super.setBackgroundDrawable((Drawable) newRipple); } rippleDrawable = newRipple; }
private void setAppBarLayoutAlpha(int alpha) { if (isForeground()) return; Activity activity; if ((activity = getActivity()) != null && mAppBarLayout != null && mToolBar != null) { int colorPrimary = ViewUtils.getColorPrimaryColor(activity); mAppBarLayout.setBackgroundDrawable(new ColorDrawable(Color.argb(alpha, Color.red(colorPrimary), Color.green(colorPrimary), Color.blue(colorPrimary)))); mToolBar.setTitleTextColor(Color.argb(alpha, 255, 255, 255)); } }