android textview 跑马灯 滚动效果

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

android:singleLine="true" 单行显示android:ellipsize="marquee" 跑马灯显示android:marqueeRepeatLimit="marquee_forever" 设置重复滚动的次数,无限次android:focusable="false" 设置是否获得焦点(当执行了setFocusable (false)后,再执行 setFocusable (true) 无法输入,也获取不了焦点了。

试了一下setFocusableInTouchMode(false)后,再执行setFocusableInTouchMode(true),可以正常输入,也能正常获取焦点。

setFocusableInTouchMode 与 setFocusable 之间有什么区别呢?)

android:scrollHorizontally="true" 超过textview宽度时,是否出现横拉条

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);---------------------------------------android:ellipsize="start" 省略号在开头
android:ellipsize="middle" 省略号在中间
android:ellipsize="end" 省略号在结尾
android:ellipsize="marquee" 跑马灯显示
或者在程序中可通过setEillpsize显式设置。
注: EditText不支持marquee这种模式。--------------------------------------
注:多个TextView同时跑马灯效果
解决方案:设置android:ellipsize="marquee",android:singleLine="true"android:marqueeRepeatLimit="marquee_forever"然后代码中只要textview.setSelected(true);就行了,不用去重写Textview返回焦点为true

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值