简体   繁体   English

如何更改 TextView 的尺寸和颜色?

[英]How to change the size and colour of a TextView?

While making my first android app I've got some problems with changing the size and color of TextView with Java code.在制作我的第一个 android 应用程序时,我在使用 Java 代码更改 TextView 的大小和颜色时遇到了一些问题。

To change the text color更改文本颜色

textView.setTextColor(ContextCompat.getColor(context, R.color.<name_of_color>));

To change the text size更改文本大小

text.setTextSize(TypedValue.COMPLEX_UNIT_SP,14);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM