【发布时间】:2014-12-05 14:03:06
【问题描述】:
所以我试图在运行时为一些 Drawable 着色,为了实现这一点,我使用自定义资源类返回着色的 Drawable。
类似:
public final class MyResources extends Resources
{
public Drawable getDrawable(int resId) throws NotFoundException {
Drawable drawable = super.getDrawable(resId);
drawable.setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
return drawable;
}
}
当drawable被设置为widget时,在一些widgets比如EditText、Buttons中drawable被改变并且过滤器丢失了。
我想要的是防止第二次设置可绘制对象:(Hackish)
【问题讨论】: