相关疑难解决方法(0)

android TextView:动态设置背景颜色不起作用

以编程方式设置android的背景颜色TextView似乎不起作用.我错过了什么!

TextView et = new TextView(activity);
et.setText("350");
et.setBackgroundColor(R.color.white);
Run Code Online (Sandbox Code Playgroud)

我的res/values文件夹中也有这个文件(colors.xml)

<resources>
        <color name="white">#ffffffff</color>
        <color name="black">#ff000000</color>
</resources>
Run Code Online (Sandbox Code Playgroud)

[编辑]:此外,设置文本颜色会导致TextView消失.

TextView c1 = new TextView(activity);
c1.setTextColor(R.color.solid_red);
c1.setText("My Text");
Run Code Online (Sandbox Code Playgroud)

android textview

159
推荐指数
7
解决办法
24万
查看次数

标签 统计

android ×1

textview ×1