Example usage for android.graphics.drawable StateListDrawable setEnterFadeDuration

List of usage examples for android.graphics.drawable StateListDrawable setEnterFadeDuration

Introduction

In this page you can find the example usage for android.graphics.drawable StateListDrawable setEnterFadeDuration.

Prototype

public void setEnterFadeDuration(int ms) 

Source Link

Document

Change the global fade duration when a new drawable is entering the scene.

Usage

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);
    }/*  w ww. jav a 2  s .  c o m*/
    return states;
}