以编程方式设置 Android 的背景颜色TextView
似乎不起作用。
我是不是漏掉了一些东西!
TextView et = new TextView(activity);
et.setText("350");
et.setBackgroundColor(R.color.white);
我的 res/values 文件夹中也有这个文件 (colors.xml)
<resources>
<color name="white">#ffffffff</color>
<color name="black">#ff000000</color>
</resources>
[编辑]:
此外,设置文本颜色会导致 TextView 消失。
TextView c1 = new TextView(activity);
c1.setTextColor(R.color.solid_red);
c1.setText("My Text");
Use et.setBackgroundResource(R.color.white);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)