如何更改Java文件的字体大小和字体颜色?

时间:2011-08-23 06:27:43

标签: java android eclipse

如何更改Eclipse中Java文件的字体颜色,大小和按钮颜色,而不是XML文件?

4 个答案:

答案 0 :(得分:10)

对于字体大小,您可以将其写为

tv.setTextSize(20.0f);

对于字体颜色,您可以将其写为

tv.setTextColor(Color.BLUE);

对于按钮背景颜色,您可以将其写为

btn.setBackgroundColor(Color.CYAN);

答案 1 :(得分:5)

button.setTextColor(Color.WHITE);
button.setBackgroundColor(Color.BLUE);

答案 2 :(得分:2)

the official documentation的“Inherited XML Attributes”段落中,您可以看到XML属性(可以从XML更改)或相关方法(可以在Java代码中使用)。

答案 3 :(得分:1)

其他人已经发布了关于如何在Java中使用它的答案,但我想这些也可以帮助你。

如何用XML实现:

相关问题