热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

TextViewellipsize=“marquee”跑马灯效果不能实现,解决

在TextView添加了<TextViewandroid:layout_android:layout_height

在TextView 添加了

        android:layout_
android:layout_
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:textSize="20sp"
android:text="Medium Text1,Medium Text2,Medium Text3,Medium Text4,Medium Text5,Medium Text6,Medium Text7" />


在部署应用后并不能实现效果,而是显示一行后,其余被截断并渐隐

查找后最简单的解决方法是添加一句 android:textIsSelectable="true" 即可触发跑马灯效果。

或者添加:android:focusable="true"
            android:focusableInTouchMode="true"

目的都是使该控件获得焦点。

        android:layout_
android:layout_
android:textIsSelectable="true"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:textSize="20sp"
android:text="Medium Text1,Medium Text2,Medium Text3,Medium Text4,Medium Text5,Medium Text6,Medium Text7" />


效果图:



在虚拟机4.4.4上测试,两种均可显示,在真机6.0测试,android:textIsSelectable="true" 会出现循环播放,但文字内容不完全显示问题。



推荐阅读
author-avatar
答你_妹
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有