Android TextView Marquee的应用实例详解

发布时间:2020-09-04 20:47:11 作者:yhz61010
来源:脚本之家 阅读:203

Android TextView Marquee的应用实例详解

亲测可能。直接上代码。

Xml代码

<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); 

说明:

XML 中以下几行是必须的:

android:ellipsize="marquee" 
android:marqueeRepeatLimit="marquee_forever" 
android:singleLine="true" 

最后别忘了,JAVA 中还需要调用 TextView 的 setSelected(true) 方法。

特别注意:

目前发现,android:singleLine="true" 这种写法需要已经被废弃了,但是目前只能这么写 Marquee 才能生效。如果换成最新的写法 android:maxLines="1",你会发现,Marquee 并不能滚动。不知道为什么。如果有知道原因的,或者有更好的写法的,

以上就是Android TextView Marquee的实例详解,如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

推荐阅读:
  1. Android开发中TextView文本过长滚动显示实现方法分析
  2. Android用过TextView实现跑马灯效果的示例

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

android textview marquee

上一篇:java利用phantomjs进行截图实例教程

下一篇:详解Jquery 遍历数组之$().each方法与$.each()方法介绍

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》