Search in sources :

Example 91 with StateListDrawable

use of android.graphics.drawable.StateListDrawable in project FlexibleAdapter by davideas.

the class DrawableUtils method getStateListDrawable.

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));
    // It seems item background is lost on scrolling out of the screen, 21 <= API <= 23
    if (!Utils.hasLollipop() || Utils.hasNougat()) {
        //android.R.integer.config_shortAnimTime
        int duration = 200;
        states.setEnterFadeDuration(duration);
        states.setExitFadeDuration(duration);
    }
    return states;
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable)

Example 92 with StateListDrawable

use of android.graphics.drawable.StateListDrawable in project UltimateRecyclerView by cymcsg.

the class FloatingActionButton method createFillDrawable.

/**
     * @param circleRect the defined rectangle
     * @param alpha      between  0 - 1
     * @return StateListDrawable
     */
protected StateListDrawable createFillDrawable(RectF circleRect, float alpha) {
    StateListDrawable drawable = new StateListDrawable();
    drawable.addState(new int[] { android.R.attr.state_pressed }, createAlphaDrawble(circleRect, mColorPressed, alpha));
    drawable.addState(new int[] {}, createAlphaDrawble(circleRect, mColorNormal, alpha));
    return drawable;
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable)

Example 93 with StateListDrawable

use of android.graphics.drawable.StateListDrawable in project UltimateRecyclerView by cymcsg.

the class FloatingActionButton method createFillDrawable.

/**
     * @param circleRect the defined rectangle
     * @return StateListDrawable
     */
protected StateListDrawable createFillDrawable(RectF circleRect) {
    StateListDrawable drawable = new StateListDrawable();
    drawable.addState(new int[] { android.R.attr.state_pressed }, createCircleDrawable(circleRect, mColorPressed));
    drawable.addState(new int[] {}, createCircleDrawable(circleRect, mColorNormal));
    return drawable;
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable)

Example 94 with StateListDrawable

use of android.graphics.drawable.StateListDrawable in project Depth-LIB-Android- by danielzeller.

the class WindFragment method setProgressBarColor.

public static void setProgressBarColor(SeekBar progressBar, int newColor) {
    if (progressBar.getProgressDrawable() instanceof StateListDrawable) {
        StateListDrawable ld = (StateListDrawable) progressBar.getProgressDrawable();
        ld.setColorFilter(newColor, PorterDuff.Mode.SRC_IN);
        progressBar.getThumb().setColorFilter(newColor, PorterDuff.Mode.SRC_IN);
    } else if (progressBar.getProgressDrawable() instanceof LayerDrawable) {
        LayerDrawable ld = (LayerDrawable) progressBar.getProgressDrawable();
        for (int i = 0; i < ld.getNumberOfLayers(); i++) {
            Drawable d1 = ld.getDrawable(i);
            d1.setColorFilter(newColor, PorterDuff.Mode.SRC_IN);
        }
        progressBar.getThumb().setColorFilter(newColor, PorterDuff.Mode.SRC_IN);
    }
}
Also used : LayerDrawable(android.graphics.drawable.LayerDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) MaterialMenuDrawable(no.agens.depth.lib.MaterialMenuDrawable) Drawable(android.graphics.drawable.Drawable) StateListDrawable(android.graphics.drawable.StateListDrawable) StateListDrawable(android.graphics.drawable.StateListDrawable)

Example 95 with StateListDrawable

use of android.graphics.drawable.StateListDrawable in project Launcher3 by chislon.

the class HolographicImageView method drawableStateChanged.

@Override
protected void drawableStateChanged() {
    super.drawableStateChanged();
    mHolographicHelper.generatePressedFocusedStates(this);
    Drawable d = getDrawable();
    if (d instanceof StateListDrawable) {
        StateListDrawable sld = (StateListDrawable) d;
        sld.setState(getDrawableState());
        sld.invalidateSelf();
    }
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable) Drawable(android.graphics.drawable.Drawable) StateListDrawable(android.graphics.drawable.StateListDrawable)

Aggregations

StateListDrawable (android.graphics.drawable.StateListDrawable)166 Drawable (android.graphics.drawable.Drawable)43 LayerDrawable (android.graphics.drawable.LayerDrawable)24 BitmapDrawable (android.graphics.drawable.BitmapDrawable)21 GradientDrawable (android.graphics.drawable.GradientDrawable)21 ColorDrawable (android.graphics.drawable.ColorDrawable)17 Bitmap (android.graphics.Bitmap)13 TextView (android.widget.TextView)12 ShapeDrawable (android.graphics.drawable.ShapeDrawable)11 View (android.view.View)11 AnimationDrawable (android.graphics.drawable.AnimationDrawable)9 ClipDrawable (android.graphics.drawable.ClipDrawable)9 SuppressLint (android.annotation.SuppressLint)8 ColorStateList (android.content.res.ColorStateList)8 Paint (android.graphics.Paint)8 RippleDrawable (android.graphics.drawable.RippleDrawable)7 TargetApi (android.annotation.TargetApi)6 TypedArray (android.content.res.TypedArray)6 TextPaint (android.text.TextPaint)5 Button (android.widget.Button)5