TextView:文本视图。

来源:互联网 发布:淘宝海外代购可信吗 编辑:程序博客网 时间:2024/05/15 11:08

组件的常见属性:

(1)对宽度影响


Android中的属性;
android:layout_width
   android:layout_width="wrap_content"  组件的宽度随内容的变化而变化。(相对于内容进行设计)其他的属性对宽度可以进行修改。
   android:layout_width="fill_parent"   组件的宽度和父窗口的一致.(相对于父容器进行设计)其他的属性对宽度不能进行修改。
android:maxWidth
android:minWidth
android:width
android:ems="2"   两个汉字的宽度
android:maxEms
android:minEms
android:maxLength
android:singleLine
android:singleLine="true"  只能为单行,若不能全部显示,后面未显示的部分用省略号代替。
(2)对高度影响的属性;
android:lines="4"  设置为四排
(3)对文本颜色影响的属性;
android:textColor 设置文本颜色
android:textColorHighlight  被选中文字的底色
(4)对文本大小影响的属性;
android:textSize 设置文字大小,推荐度量单位“sp”,如“15sp”
(5)对文本样式影响的属性;
android:textStyle  设置字形[bold(粗体)0,italic(斜体)1,bolditalic(又粗又斜) 2 ]可以设置一个或多个,用“|”隔开
android:typeface 设置文本字体,
(6)对文本位置影响的属性;必须是以下常量值之一:normal 0,sans 1,serif 2,monospace(等宽字体) 3
android:gravity    设置文本位置,如设置成“center”,文本将居中显示。
(7)文本动态性(走马灯效果);
android:ellipsize="marquee"
       android:marqueeRepeatLimit="marquee_forever"
       android:focusable="true"
       android:focusableInTouchMode="true"
0 0
原创粉丝点击