layout文本相关

Textview t=findViewById(R.id.t);

 

ONE设置文本内容:

在XML中android:text直接写

在java中setText()中修改

注意点1继承appcompatactivity

注意点2覆写单参数的oncreate方法,在里面setcontentview新的变量

例:R.layout.activity_main

其中R是类名(资源的意思) layout是页面布局 activity_main则是layout内的详细内容

关于setText的修改

两种:1,setText(R.string.name)//这时文本中的内容使用value.string元素

2,setText(内容)

TWO设置文本字体

在JAVA中setTextSize();//里面默认为sp单位

在XML中android:textSize,注意指定字号单位

 

 

 

 

THREE设置文本颜色

在JAVA中setTextColor();

 

 

 

在XML中android:textColor

 

 

 

 

xml中android:background

java中设置系统的背景颜色

setBackgroundColor(Color.GREEN);//系统自带颜色
setBackgoroundResource(R.color.green);//使用自己库里的颜色

 

posted @ 2022-12-27 17:54  天启A  阅读(36)  评论(0)    收藏  举报