android字体颜色如何设置?

2025-03-23 05:46:30
推荐回答(2个)
回答1:


由于你没有自己定义颜色,默认为灰色。

有两种方式设置:

1:在java类中

    TextView tv = new TextView(this);
    tv.setTextColor(Color.RED);
利用这种方式设置字体颜色。

2:在xml文件中

    

            android:id="@+id/email"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="邮箱"
        android:textColor=""
        />

在你的TextView中有textColor属性,给属性值为RGB格式就行了.

回答2:

TextView tv = new TextView(this);
tv.setTextColor(Color.RED);
利用这种方式设置字体颜色。
由于你没有自己定义颜色,默认为灰色。