在Android中以编程方式在FrameLayout中设置前景色 [英] set foreground color in FrameLayout in android programmatically
本文介绍了在Android中以编程方式在FrameLayout中设置前景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想实用地在FrameLayout中设置前景色(而不是在XML属性中)。
我在 RGB
I want to set foreground color in FrameLayout pragmatically (not in XML attribute).
I have the color codes in RGB
如何将颜色转换为可绘制的颜色...
How can I convert color to drawable...
frm.setForeground(Drawable);
帮助!谢谢
推荐答案
您可以从颜色创建 Drawable
:
final int color = 0xFFFF0000;
final Drawable drawable = new ColorDrawable(color);
这篇关于在Android中以编程方式在FrameLayout中设置前景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文