开发者

How do change the font size and font color from a Java file?

How can I change the font color, size and 开发者_如何学Gobutton color from a Java file in Eclipse, not from an XML file?


For font size you can write it as

tv.setTextSize(20.0f);

For font color you can write it as

tv.setTextColor(Color.BLUE);

For button background color you can write it as

btn.setBackgroundColor(Color.CYAN);


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


In the "Inherited XML Attributes" paragraph of the official documentation you can see either XML attributes (that you can change from XML) or related methods (which you can use in your Java code).


Others already posted answers on how to do it in Java, but I guess these could help you as well.

How to do it in XML:

  • Font Styling

  • Button Styling --Link changed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜