List of usage examples for android.graphics.drawable Drawable setState
public boolean setState(@NonNull final int[] stateSet)
From source file:Main.java
public static void clearState(Drawable drawable) { if (drawable != null) { drawable.setState(EMPTY_STATE); } }
From source file:Main.java
public static void forceStateChange(Drawable drawable, boolean forceOnChildren) { drawable.setState(getForceState(drawable.getState())); if (forceOnChildren) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { forceStateChangeOnChildrenCompat(drawable); } else {//from w w w .ja v a 2s .c o m forceStateChangeOnChildren(drawable); } } }
From source file:Main.java
@SuppressLint("NewApi") public static void clearDrawableAnimation(View view) { if (Build.VERSION.SDK_INT < 21 || view == null) { return;// ww w . j a v a2s . c om } Drawable drawable; if (view instanceof ListView) { drawable = ((ListView) view).getSelector(); if (drawable != null) { drawable.setState(StateSet.NOTHING); } } else { drawable = view.getBackground(); if (drawable != null) { drawable.setState(StateSet.NOTHING); drawable.jumpToCurrentState(); } } }
From source file:Main.java
public static void clearDrawableAnimation(View view) { if (Build.VERSION.SDK_INT < 21 || view == null) { return;/* w ww. j a va2 s . com*/ } Drawable drawable = null; if (view instanceof ListView) { drawable = ((ListView) view).getSelector(); if (drawable != null) { drawable.setState(StateSet.NOTHING); } } else { drawable = view.getBackground(); if (drawable != null) { drawable.setState(StateSet.NOTHING); drawable.jumpToCurrentState(); } } }
From source file:Main.java
/** * Copies various properties from one drawable to the other. * @param to drawable to copy properties to * @param from drawable to copy properties from *///from w ww.ja v a 2 s .com public static void copyProperties(Drawable to, Drawable from) { if (from == null || to == null || to == from) { return; } to.setBounds(from.getBounds()); to.setChangingConfigurations(from.getChangingConfigurations()); to.setLevel(from.getLevel()); to.setVisible(from.isVisible(), /* restart */false); to.setState(from.getState()); }
From source file:android.support.v7.widget.DrawableUtils.java
/** * VectorDrawable has an issue on API 21 where it sometimes doesn't create its tint filter. * Fixed by toggling it's state to force a filter creation. *//*from w ww. j a va 2s .co m*/ private static void fixVectorDrawableTinting(final Drawable drawable) { final int[] originalState = drawable.getState(); if (originalState == null || originalState.length == 0) { // The drawable doesn't have a state, so set it to be checked drawable.setState(ThemeUtils.CHECKED_STATE_SET); } else { // Else the drawable does have a state, so clear it drawable.setState(ThemeUtils.EMPTY_STATE_SET); } // Now set the original state drawable.setState(originalState); }
From source file:com.facebook.litho.ComponentHostUtils.java
/** * Sets the state on a drawable if it is clickable or should duplicate its parent's state. *//*from ww w .j a va 2 s .c o m*/ static void maybeSetDrawableState(View view, Drawable drawable, int flags, NodeInfo nodeInfo) { final boolean shouldSetState = (nodeInfo != null && nodeInfo.hasTouchEventHandlers()) || MountItem.isDuplicateParentState(flags); if (shouldSetState && drawable.isStateful()) { drawable.setState(view.getDrawableState()); } }
From source file:net.xpece.android.support.preference.SeekBarPreference.java
private static void fixDrawableStateOnAndroid2(final SeekBar seekBar) {// Fix drawable state on Android 2. if (Build.VERSION.SDK_INT < 14) { final int[] state = seekBar.getDrawableState(); Drawable d; d = SeekBarCompat.getThumb(seekBar); if (d != null) d.setState(state); d = seekBar.getProgressDrawable(); if (d != null) d.setState(state);//from w w w. j a v a 2 s .co m d = seekBar.getIndeterminateDrawable(); if (d != null) d.setState(state); d = seekBar.getBackground(); if (d != null) d.setState(state); } }
From source file:me.henrytao.mdcore.core.MdCompat.java
public static Drawable createDrawableTint(Drawable drawable, int[] drawableState, ColorStateList tintList, PorterDuff.Mode tintMode) {/*from ww w .j av a2s.c o m*/ if (drawable != null && (tintList != null || tintMode != null)) { drawable = DrawableCompat.wrap(drawable).mutate(); if (tintList != null) { DrawableCompat.setTintList(drawable, tintList); } if (tintMode != null) { DrawableCompat.setTintMode(drawable, tintMode); } if (drawable.isStateful() && drawableState != null) { drawable.setState(drawableState); } } return drawable; }
From source file:com.negusoft.greenmatter.drawable.CompoundDrawableWrapper.java
@Override public boolean setState(final int[] stateSet) { for (Drawable d : mSecondaryDrawables) d.setState(stateSet); return super.setState(stateSet); }