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;
}
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;
}
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;
}
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);
}
}
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();
}
}
Aggregations