以编程方式设置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");
最佳答案
使用et.setBackgroundResource(R.color.white);