我是靠谱客的博主 独特美女,这篇文章主要介绍TextView实现跑马灯效果 以以实现TextView没有边框 设置我们自己的背景,现在分享给大家,希望可以做个参考。


<TextView 
android:layout_width="100px"
android:layout_height
="wrap_content" 
android:text
="234254fadfadffadfadfgfhdgfhjhfjhfjhjfhjfhjfhjfhjtyteytryet" 
android:marqueeRepeatLimit
="marquee_forever"
android:ellipsize
="marquee" 
android:scrollHorizontally
="true"
android:focusableInTouchMode
="true"
android:focusable
="true"></TextView>


复制代码
1
2
android:layout_width="100px"   //文字宽度不能是wrap_content(后面更正,可以是!),//这样的跑步起来
复制代码
1
2
3
4
5
6
android:marqueeRepeatLimit="marquee_forever"//表示滚动回数,这里这么设置,表示一直滚动         android:ellipsize="start"        省略号在开头                android:ellipsize="middle"       省略号在中间                android:ellipsize="end"          省略号在结尾                android:ellipsize="marquee"      跑马灯显示         或者在程序中可通过setEillpsize显式设置。
复制代码
1
android:focusable="true"  //要显示该跑马灯,view必须要获得焦点,只有在取得焦点的情况下跑马灯才会显示


复制代码
1
2
3
4
更新: 用此例在android4.0.3上不能跑起来跑马灯的效果,需加 android:singleLine="true" 当为一行的时候,才有跑马灯效果。


复制代码
1
(4)android:focusableInTouchMode:是否在触摸模式下获得焦点。



除了跑马灯之外     我们还可以通过 scrollView  来实现我们的textview滚动显示。



TextView出去边框就是我们设置背景位null







最后

以上就是独特美女最近收集整理的关于TextView实现跑马灯效果 以以实现TextView没有边框 设置我们自己的背景的全部内容,更多相关TextView实现跑马灯效果内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(76)

评论列表共有 0 条评论

立即
投稿
返回
顶部