-
TextView
继承View
,作用就是在界面上显示文本(类似于iOS
中的UILabel
),同时它还是EditText
、Button
两个UI
组件类的父类。 -
另外
Android
关闭了它的文字编辑功能,如果想编辑内容,则可以使用EditText
。
TextView
常用属性
| 属性 | 含义 |
| — | — |
| id | 为 TextView
设置一个组件 id
,根据 id
,可以在 Java
代码中通过findViewById()
的方法获取到该对象,然后进行相关属性的设置。 |
| layout_width | 组件宽度 |
| layout_height | 组件高度 |
| text | 设置显示的文本内容,通常是把字符串写到 res/values/strings.xml
文件中, 然后通过 @string/xxx
取得对应的字符串内容。 |
| textSize | 字体大小,单位一般是用 sp
。 |
| textColor | 设置字体颜色,同上,通过 res/values/colors.xml
资源来引用(使用:@color/xxx
) |
| textStyle | 设置字体风格,三个可选值: normal
(无效果)、bold
(加粗)、 italic
(斜体)。 |
| autoLink | 识别链接类型:web
、email
、phone
、map
、none
、