Android TextView Marquee Android TextView Marquee的应用实例详解

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

Android TextView Marquee Android TextView Marquee的应用实例详解

yhz61010   2021-03-26 我要评论
想了解Android TextView Marquee的应用实例详解的相关内容吗,yhz61010在本文为您仔细讲解Android TextView Marquee的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:Android,TextView,Marquee,Android,TextView,Marquee的实例详解,下面大家一起来学习吧。

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的实例详解,如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

猜您喜欢

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们