【发布时间】:2015-06-19 19:02:32
【问题描述】:
我正在使用 DrawableCompat.wrap 为 pre Lollipop 中的可绘制对象设置色调,它工作正常。 DrawableCompat.unwrap 在 Lollipop 之前不起作用。 我无法在着色之前获得原始可绘制对象。
例如:
if (v.isSelected()){
Drawable normalDrawable = getResources().getDrawable(R.drawable.sample);
Drawable wrapDrawable = DrawableCompat.wrap(normalDrawable);
DrawableCompat.setTint(wrapDrawable, getResources().getColor(R.color.sample_color));
imageButton.setImageDrawable(wrapDrawable);
}else{
Drawable normalDrawable = imageButton.getDrawable();
Drawable unwrapDrawable = DrawableCompat.unwrap(normalDrawable);
imageButton.setImageDrawable(unwrapDrawable);
}
在棒棒糖之前的设备中,DrawableCompact.unwrap 返回带有色调而不是原始颜色的可绘制对象
【问题讨论】:
-
有这方面的消息吗?你找到解决办法了吗?
-
@chrisonline 没什么新鲜的。由于这种行为,我们没有使用此功能,这很不幸,因为它是一个强大的工具。
标签: android android-5.0-lollipop drawable android-support-library tint