以编程方式更改绘制颜色 [英] Change drawable color programmatically
本文介绍了以编程方式更改绘制颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过code改变白色标记图像的颜色。我已阅读了code以下应改变颜色,但我的标记仍然是白色的。
I'm trying to change the color on a white marker image by code. I have read that the code below should change the color, but my marker remains white.
Drawable.setColorFilter( 0xffff0000, Mode.MULTIPLY )
我错过了什么?是否有任何其他的方式来改变我可绘设在我的资源文件夹的颜色?
Did I miss something? Is there any other way to change colors on my drawables located in my res folder?
推荐答案
试试这个:
Drawable mDrawable = context.getResources().getDrawable(R.drawable.balloons);
mDrawable.setColorFilter(new
PorterDuffColorFilter(0xffff00,PorterDuff.Mode.MULTIPLY));
这篇关于以编程方式更改绘制颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文