List of usage examples for android.graphics.drawable StateListDrawable setExitFadeDuration
public void setExitFadeDuration(int ms)
From source file:com.sbgapps.simplenumberpicker.utils.ThemeUtil.java
public static StateListDrawable makeSelector(Context context, int drawableResId, int color) { StateListDrawable res = new StateListDrawable(); res.setExitFadeDuration(50); Drawable drawable = ContextCompat.getDrawable(context, drawableResId); DrawableCompat.setTint(drawable, color); res.addState(new int[] { android.R.attr.state_enabled }, drawable); drawable = ContextCompat.getDrawable(context, drawableResId); DrawableCompat.setTint(drawable, color & 0x40FFFFFF); res.addState(new int[] { -android.R.attr.state_enabled }, drawable); return res;//from www. j a v a2 s. co m }
From source file:com.flexible.flexibleadapter.utils.DrawableUtils.java
private static StateListDrawable getStateListDrawable(@ColorInt int normalColor, @ColorInt int pressedColor) { StateListDrawable states = new StateListDrawable(); states.addState(new int[] { android.R.attr.state_activated }, getColorDrawable(pressedColor)); states.addState(new int[] {}, getColorDrawable(normalColor)); // Animating across states. // It seems item background is lost on scrolling out of the screen, 21 <= API <= 23 if (!Utils.hasLollipop() || Utils.hasNougat()) { int duration = 200; //android.R.integer.config_shortAnimTime states.setEnterFadeDuration(duration); states.setExitFadeDuration(duration); }// www . j a va 2 s. c o m return states; }