如何更改Android应用中的文字颜色

时间:2013-10-17 00:31:52

标签: java android styles

这个问题可能如此简单,但作为初学者我很难。我正在开发java的Android应用程序。所以有一个TextView。

如何添加一些样式。喜欢改变它的颜色,字体等??

2 个答案:

答案 0 :(得分:0)

这将改变xml:

的颜色
<TextView
android:layout_width="wrap_content"
android:layout_height"wrap_content"
android:textColor="#123123"
/>

更改字体的深度要多一些。将所需的字体文件放入项目的assets文件夹中,并使用TextView的setTypeface()方法。上一个问题已经涵盖了这一点:How to change the font on the TextView?

答案 1 :(得分:0)

好的,这是TextView的文档。基本上有两种方法可以使用xml和java代码设置文本视图的样式。这是相关的xml属性:

android:textColor
android:textColorHighlight
android:textColorHint
android:textSize

等等。在代码上它看起来像这样:

TextView tv = (TextView) findViewById(R.id.tv);
tv.setTextColor(Color.BLACK);