开发者

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

开发者 https://www.devze.com 2023-03-30 15:05 出处:网络
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

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

精彩评论

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