在自学AndroidAPP开发中学习到了TextView的“跑马灯”效果,感觉很有意思,但是中间出现了已些问题,自己总结了一下。
喜欢的朋友可以看下~
先看代码,很简单。
<TextView android:layout_width="60dp" android:layout_height="wrap_content" android:text="我是跑马灯哈哈哈哈哈哈" android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:focusable="true" android:focusableInTouchMode="true" />将以上TextView的八个属性均设置好后就可以实现“跑马灯”效果喽~。
但是有几点需要注意:
1.layout_width宽度属性不可以设置为match_parent或者wrap_content,必须设置为定长(貌似要小于等于文本的长度)
2.singleLine属性必须设为true,此属性已过期但是仍可以继续使用;新属性为maxLines,可以设置行数,但是无法实现跑马灯效果
3.其他属性均要设置,缺一不可。
好啦,想要用TextView实现”跑马灯“效果的盆友快去试试吧~