android marquee TextView
来源:互联网 发布:linux系统操作命令 编辑:程序博客网 时间:2024/06/05 06:35
项目开发中有些时候TextView的文本内容太长了显示不全,这个时候需要让它实现像网页上面的跑马灯效果,网上很多文章都是自定义控件继承自TextView来实现的,自己在实践中发现不用自定义控件也可以实现跑马灯的效果,因为Android原生的TextView已经支持跑马灯的效果了。
关键之处在于设置TextView的四个属性值:
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
尤其是下面两个属性:
android:focusable="true"
android:focusableInTouchMode="true"
只有当它获取到焦点的时候才会滚动。
完整布局如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" android:orientation="vertical"> <TextView android:id="@+id/tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:marqueeRepeatLimit="marquee_forever" android:singleLine="true" android:text="@string/txt_title" android:textSize="15sp"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/confirm" android:textSize="15sp"/></LinearLayout>
0 0
- android marquee TextView
- TextView Marquee
- Android TextView 跑马灯效果 android:ellipsize="marquee"
- 亲测Android TextView的文字滚动(marquee)效果
- 使TextView组件的android:ellipsize="marquee"属性生效
- Android 解决通知栏中TextView marquee 没起作用问题
- TextView设置android:ellipsize=marquee不滚动
- Android TextView实现滚动跑马灯效果Marquee
- Android TextView的marquee跑马灯无效的坑
- TextView属性android:ellipsize="marquee"不生效的解决办法
- android TextView 设置Marquee无效问题,最简便的设置
- TextView title 文字过多滚动 TextView属性android:ellipsize="marquee"不生效的解决办法
- android 如何让appwidget 里面设置TextView 滚动,android widget marquee text
- TextView设置android:ellipsize="marquee"属性,无法实现跑马灯效果的解决方法
- 如何实现TextView的Marquee效果
- TextView:ellipsize设置了Marquee显示省略号
- 使用TextView实现跑马灯Marquee
- Android跑马灯Marquee
- 腾讯原创出品《你正常吗》今开播 模式新颖亮点多
- php开发环境搭建
- 我国标准与国际标准的关系
- java 汉字转Unicode
- 23种设计模式(13):迭代器模式
- android marquee TextView
- 使用graphviz dot来画图表
- 使用暴力反射让Spinner选择同一选项时触发onItemSelected事件
- ZK Intbox的Constraint
- php伪静态的一些注意事项
- fedora64位下配置android报错解决方案
- LeetCode刷题笔录 Reorder List
- 【UX】【Android动画】之Tween动画 (渐变、缩放、位移、旋转)
- Configure,Makefile.am, Makefile.in, Makefile文件之间关系