您的位置:首页 > 其它

TextView实现跑马灯效果

2016-01-29 15:25 295 查看
TextView实现跑马灯只需要设置TextView的四个属性:

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"/>

分别是singleLine设置为true:让内容显示在一行上,不设置会有折行,一行空间不够会自动转到下一行。

ellipsize设置为marquee跑马灯效果,如果设置为start是在开头缩进(开头是省略号),end是在末尾缩进(末尾是省略号),middle是中间缩进(中间是省略号)。

focusable是让TextView获取焦点。

以上即可实现TextView的跑马灯效果。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: