android 设置文字跑马灯效果

本文介绍如何通过设置TextView属性及代码实现文字滚动显示效果。关键在于使用XML设置TextView的单行显示、省略号样式、无限重复滚动、不可聚焦及水平滚动等属性,并通过程序代码设置TextView为选中状态。

 from stackoverflow,

the key point is:

myTextView.setSelected(true);

it's easy to do via XML. Use the following settings:

android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:focusable="false" android:scrollHorizontally="true"

If your TextView is within a RelativeLayout, the width or height will have to be static (i.e. 32dp). If you need dynamic, place the TextView in another View within the RelativeLayout.

In onCreate(), you need to make the TextView selected:

myTextView.setSelected(true);

转载于:https://my.oschina.net/zhangqingcai/blog/87739

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值