【问题标题】:Tint a drawable pre Lollipop为可绘制的棒棒糖前着色
【发布时间】: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被改变并且过滤器丢失了。

真实代码在:https://github.com/SiegenthalerSolutions/QuantumPaper/blob/master/library/src/main/java/me/siegenthaler/quantum_paper/QuantumResources.java

我想要的是防止第二次设置可绘制对象:(Hackish)

https://github.com/SiegenthalerSolutions/QuantumPaper/blob/master/library/src/main/java/me/siegenthaler/quantum_paper/interceptor/SimpleBackgroundInterceptor.java

【问题讨论】:

    标签: java android


    【解决方案1】:

    试试我的图书馆。我实现了一个特殊的drawable来为自定义EditText着色drawable。这也适用于所有其他情况。

    https://github.com/rekire/TintedDrawable

    【讨论】:

      猜你喜欢
      • 2018-10-08
      • 2015-09-10
      • 2015-09-01
      • 2023-03-21
      • 2018-09-19
      • 1970-01-01
      • 2015-03-12
      • 1970-01-01
      • 2015-08-12
      相关资源
      最近更新 更多