Android TextView跑马灯效果
来源:互联网 发布:ubuntu下移动文件夹 编辑:程序博客网 时间:2024/04/30 14:50
当设置布局文件中TextView的
android:singleLine="true"
时,TextView的内容将以单行显示。此时,如果内容过长,将显示不全,并在行末用...来表示。
此时,想要全部显示内容,又不影响布局,可以使用TextView的跑马灯效果。所谓跑马灯效果,就是将内容以滚动效果显示。
如果布局中只有一个TextView 可在布局文件的TextView属性中作如下设置:
android:singleLine="true"android:ellipsize="marquee"android:focusable="true"android:focusableInTouchMode="true"如果布局中有多个TextView且都需要使用跑马效果 需要进行下面这些操作:
0.创建 MarqueeTextView 类(类名随意) 继承 TextView 并实现三个构造方法(来源于TextView) 重写isFocused()方法
package org.xring.marquee;import android.content.Context;import android.util.AttributeSet;import android.widget.TextView;/** * Created by xring on 10/25/14. */public class MarqueeTextView extends TextView { public MarqueeTextView(Context context) { super(context); } public MarqueeTextView(Context context, AttributeSet attrs) { super(context, attrs); } public MarqueeTextView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Override public boolean isFocused() { return true; }}1.在布局文件中使用我们自己创建的 带包名的 MarqueeTextView
<org.xring.marquee.MarqueeTextView android:text="abcdefghijklnmopqrstuvwxyzabcdefghijklnmopqrstuvwxyz" android:singleLine="true" android:focusable="true" android:ellipsize="marquee" android:focusableInTouchMode="true" android:layout_width="wrap_content" android:layout_height="wrap_content" />2.跑马灯效果实现 如果有多个TextView需要跑马灯效果 在布局文件中使用多个 带包名的 MarqueeTextView
0 0
- Android TextView跑马灯效果
- Android TextView跑马灯效果
- Android TextView跑马灯效果
- Android TextView跑马灯效果
- [Android]TextView跑马灯效果
- Android textView 跑马灯效果
- android TextView 跑马灯效果
- Android TextView跑马灯效果
- Android TextView跑马灯效果
- Android TextView跑马灯效果
- android TextView跑马灯效果
- android TextView跑马灯效果
- Android TextView跑马灯效果
- Android TextView跑马灯效果
- android textView跑马灯效果
- Android TextView 跑马灯效果
- Android TextView跑马灯效果
- android textview 跑马灯效果
- hibernate注解之简介(一)
- 访问权限控制
- python django 建表时的问题
- JQuery学习笔记之过滤性选择器
- asio学习笔记2
- Android TextView跑马灯效果
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第15章节--开发SP2013工作流应用程序 SPD的新功能
- PHP的几种运行模式
- hibernate学习从XML入手
- 一些常见的端口
- 【Leetcode】Rotate List (lastN)
- 第9周 项目3-3 编程输出星图(c)
- Mac下使用Cocos2d-x Lua加载Cocos Studio到处的Json文件和动画
- hibernate注解之主键生成策略(二)