源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Android TextView Marquee的应用实例详解

  • 时间:2020-07-21 13:17 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Android TextView Marquee的应用实例详解
[b]Android TextView Marquee的应用实例详解[/b] 亲测可能。直接上代码。 [b]Xml代码[/b]
<TextView 
  android:id="@+id/toolbar_title" 
  android:layout_width="match_parent" 
  android:layout_height="wrap_content" 
  android:layout_gravity="center_vertical" 
  android:fadingEdge="none" 
  android:focusable="true" 
  android:focusableInTouchMode="true" 
  android:freezesText="true" 
  android:ellipsize="marquee" 
  android:marqueeRepeatLimit="marquee_forever" 
  android:singleLine="true" 
  android:scrollHorizontally="true" 
  android:textColor="#fff" 
  android:textSize="16sp" /> 

mToolbarTitle.setSelected(true); 
[b]说明: [/b] XML 中以下几行是必须的:
android:ellipsize="marquee" 
android:marqueeRepeatLimit="marquee_forever" 
android:singleLine="true" 
最后别忘了,JAVA 中还需要调用 TextView 的 setSelected(true) 方法。 [b]特别注意: [/b] 目前发现,android:singleLine="true" 这种写法需要已经被废弃了,但是目前只能这么写 Marquee 才能生效。如果换成最新的写法 android:maxLines="1",你会发现,Marquee 并不能滚动。不知道为什么。如果有知道原因的,或者有更好的写法的, 以上就是Android TextView Marquee的实例详解,如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部