本文整理了Java中android.graphics.drawable.Drawable.getState()
方法的一些代码示例,展示了Drawable.getState()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Drawable.getState()
方法的具体详情如下:
包路径:android.graphics.drawable.Drawable
类名称:Drawable
方法名:getState
暂无
代码示例来源:origin: rey5137/material
@Override
public int[] getState() {
return mDrawable != null ? mDrawable.getState() : null;
}
代码示例来源:origin: facebook/litho
@Override
public int[] getState() {
return mDrawable.getState();
}
代码示例来源:origin: facebook/litho
@Override
public int[] getState() {
return mDrawable.getState();
}
代码示例来源:origin: facebook/litho
@Override
public @Nullable int[] getState() {
return mDrawable == null ? null : mDrawable.getState();
}
代码示例来源:origin: seven332/EhViewer
@NonNull
public int[] getState() {
return this.mDrawable.getState();
}
代码示例来源:origin: ZieIony/Carbon
public static void setTintList(Drawable drawable, ColorStateList tint) {
drawable.mutate();
if (Carbon.IS_LOLLIPOP_OR_HIGHER) {
drawable.setTintList(tint);
} else if (drawable instanceof TintAwareDrawable) {
((TintAwareDrawable) drawable).setTintList(tint);
} else {
drawable.setColorFilter(tint == null ? null : new PorterDuffColorFilter(tint.getColorForState(drawable.getState(), tint.getDefaultColor()), PorterDuff.Mode.MULTIPLY));
}
}
代码示例来源:origin: ZieIony/Carbon
public static void setTintListMode(Drawable drawable, ColorStateList tint, PorterDuff.Mode mode) {
drawable.mutate();
if (Carbon.IS_LOLLIPOP_OR_HIGHER) {
drawable.setTintList(tint);
drawable.setTintMode(mode);
} else if (drawable instanceof TintAwareDrawable) {
((TintAwareDrawable) drawable).setTintList(tint);
((TintAwareDrawable) drawable).setTintMode(mode);
} else {
drawable.setColorFilter(tint == null ? null : new PorterDuffColorFilter(tint.getColorForState(drawable.getState(), tint.getDefaultColor()), mode));
}
}
代码示例来源:origin: aa112901/remusic
private Drawable applySupportCompoundDrawableTint(int position) {
Drawable originDrawable = ((TextView) mView).getCompoundDrawables()[position];
Drawable compoundDrawable = originDrawable;
TintInfo tintInfo = mCompoundDrawableTintInfos[position];
if (compoundDrawable != null && tintInfo != null && tintInfo.mHasTintList) {
compoundDrawable = DrawableCompat.wrap(compoundDrawable);
compoundDrawable.mutate();
if (tintInfo.mHasTintList) {
DrawableCompat.setTintList(compoundDrawable, tintInfo.mTintList);
}
if (tintInfo.mHasTintMode) {
DrawableCompat.setTintMode(compoundDrawable, tintInfo.mTintMode);
}
if (compoundDrawable.isStateful()) {
compoundDrawable.setState(originDrawable.getState());
}
return compoundDrawable;
}
return originDrawable;
}
代码示例来源:origin: AlexMofer/ProjectX
@Override
public int[] getState() {
if (mDrawable == null)
return super.getState();
return mDrawable.getState();
}
代码示例来源:origin: posm/OpenMapKitAndroid
public static boolean isCacheDrawableExpired(Drawable drawable) {
if (drawable != null && drawable.getState() == EXPIRED) {
return true;
}
return false;
}
代码示例来源:origin: 1993hzw/Androids
@Override
public int[] getState() {
return baseDrawable == null ? null : baseDrawable.getState();
}
代码示例来源:origin: AlexMofer/ProjectX
public int[] getState() {
return this.mDrawable.getState();
}
代码示例来源:origin: com.madgag/lazy-drawables
public int[] getState() {
return mCurrDrawable.getState();
}
代码示例来源:origin: MCMrARM/revolution-irc
@NonNull
@Override
public int[] getState() {
return mDrawable.getState();
}
代码示例来源:origin: dongorigin/AndroidDemo
private void printState(Drawable drawable) {
int[] ints = drawable.getState();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < ints.length; i++) {
sb.append("i:").append(ints[i]).append(" ");
}
Log.d("drawable", sb.toString());
}
代码示例来源:origin: AlexMofer/ProjectX
@Override
public int[] getState() {
if (mDrawable == null)
return super.getState();
return mDrawable.getState();
}
代码示例来源:origin: com.albedinsky.android/ui-graphics-base
/**
* Crates a new instance of PorterDuffColorFilter with color obtained from the specified <var>tint</var>
* colors for the current state of the specified <var>drawable</var>.
*
* @param drawable The drawable used to resolve proper tint color based on its current state.
* @param tint Set of available tint colors.
* @param tintMode Blending mode for the new color filter.
* @return New PorterDuffColorFilter with the resolved color and the specified <var>tintMode</var>.
*/
@Nullable
public static PorterDuffColorFilter createTintFilter(@NonNull Drawable drawable, @Nullable ColorStateList tint, @Nullable PorterDuff.Mode tintMode) {
if (tint == null || tintMode == null) {
return null;
}
return new PorterDuffColorFilter(tint.getColorForState(drawable.getState(), Color.TRANSPARENT), tintMode);
}
代码示例来源:origin: com.albedinsky.android/ui-graphics
/**
* Crates a new instance of PorterDuffColorFilter with color obtained from the specified <var>tint</var>
* colors for the current state of the specified <var>drawable</var>.
*
* @param drawable The drawable used to resolve proper tint color based on its current state.
* @param tint Set of available tint colors.
* @param tintMode Blending mode for the new color filter.
* @return New PorterDuffColorFilter with the resolved color and the specified <var>tintMode</var>.
*/
@Nullable
public static PorterDuffColorFilter createTintFilter(@NonNull Drawable drawable, @Nullable ColorStateList tint, @Nullable PorterDuff.Mode tintMode) {
if (tint == null || tintMode == null) {
return null;
}
return new PorterDuffColorFilter(tint.getColorForState(drawable.getState(), Color.TRANSPARENT), tintMode);
}
代码示例来源:origin: yydcdut/RxMarkdown
private 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(), false);
to.setState(from.getState());
}
代码示例来源:origin: AlexMofer/ProjectX
public final void setWrappedDrawable(Drawable dr) {
if (this.mDrawable != null) {
this.mDrawable.setCallback((Callback) null);
}
this.mDrawable = dr;
if (dr != null) {
dr.setCallback(this);
this.setVisible(dr.isVisible(), true);
this.setState(dr.getState());
this.setLevel(dr.getLevel());
this.setBounds(dr.getBounds());
if (this.mState != null) {
this.mState.mDrawableState = dr.getConstantState();
}
}
this.invalidateSelf();
}
内容来源于网络,如有侵权,请联系作者删除!