Android基础控件TextView

TextView是一种文本控件,它继承自View,处于android.widget包下,其主要有以下一些常见的属性

属性

说明

android:id= "@+id/id_name"

设置组件的id,用于在java中查找

android:layout_width =" "

设置组件的宽度

android:layout_height=" "

设置组件的高度

android:layout_weight=" "

设置组件所占的权重比

android:background=" "

设置文本控件的背景颜色

android:text=" "

设置文档控件显示的文本

android:textSize=" "

设置文字的大小

android:textColor=" "

设置文字的颜色

android:paddingTop=" "

设置文字与本控件上边间距

android:paddingBottom=" "

设置文字与本控件下边间距

android:paddingLeft=" "

设置文字与本控件左边间距

android:paddingRight=" "

设置文字与本控件右边间距

android:padding=" "

设置文字与本控件四周间距(控件内边距)

android:layout_gravity=" "

设置控件本身在父控件中的显示位置

android:gravity =" "

设置控件中文本的显示位置

android:layout_marginTop=" "

设置本控件与上边元素的间距

android:layout_marginBootom=" "

设置本控件与下边元素的间距

android:layout_marginLeft=" "

设置本控件与左边元素的间距

android:layout_marginRight=" "

设置本控件与右边元素的间距

android:layout_margin=" "

设置本控件与四周元素的间距(控件外边距)

android:autoLink="phone"

当文本设置为URL链接/email/电话号码/map时,文本显示为可点击的链接

android:singleLine=" "

设置控件中文本是否作单行显示

..........................................................................

 

TextView的跑马灯效果的实现:

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#FF00FF"
    android:singleLine="true"
    android:textSize="24sp"
    android:ellipsize="marquee"
    android:marqueeRepeatLimit="marquee_forever"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:scrollHorizontally="true"
    android:text="for you, one thousands times over;  爱情就像影子,如果踩中了,就请带走我的心;  暮去朝来即老,人生不饮何为"/>

运行后的效果是一行文字从右向左不断播送。就像是超市前滚动的电子显示屏

posted on 2016-07-19 16:36  Rocking7189  阅读(196)  评论(0)    收藏  举报

导航