TextView tvName = new TextView(this);
tvName.setText(ttyName);
tvName.setTextSize(28);
tvName.setBackgroundColor(Color.WHITE);
或者:
view.setBackgroundColor(Color.parseColor("#颜色值"));
XML文件中:
android:textColor="@android:color/white"
本文介绍如何在Android应用中使用Java代码及XML布局文件为TextView组件设置文本颜色和背景色。通过实例展示了直接在代码中设置颜色值以及通过XML属性进行配置的方法。
TextView tvName = new TextView(this);
tvName.setText(ttyName);
tvName.setTextSize(28);
tvName.setBackgroundColor(Color.WHITE);
或者:
view.setBackgroundColor(Color.parseColor("#颜色值"));
XML文件中:
android:textColor="@android:color/white"

被折叠的 条评论
为什么被折叠?