TextView跑马灯效果
来源:互联网 发布:敬游软件 编辑:程序博客网 时间:2024/05/18 14:44
在TextView中加上属性:
android:ellipsize = “end” 省略号在结尾
android:ellipsize = “start” 省略号在开头
android:ellipsize = “middle” 省略号在中间
android:ellipsize = “marquee” 跑马灯 (EditText不支持marquee)
android:focusable=”true”
android:focusableInTouchMode=”true”
android:singleLine=”true”只用一行显示
<com.a.pao.Run //使用自定义的类,包名.类名 android:id="@+id/tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:singleLine="true"/> <com.a.pao.Run android:layout_below="@+id/tv" android:layout_marginTop="20dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:singleLine="true"/>
在包里新建一个类:
先初始化构造函数(右键->Sourse -> Generate Constructors from Superclass)
package com.a.pao;import android.content.Context;import android.util.AttributeSet;import android.widget.TextView;public class Run extends TextView{ //该类继承了TextView public Run(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // TODO Auto-generated constructor stub } public Run(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub } public Run(Context context) { super(context); // TODO Auto-generated constructor stub } @Override public boolean isFocused(){ return true; }}
然后关键点是:
@Override public boolean isFocused(){ return true; }
默认情况下第一个Text得到焦点,而第二个则没有。 上面使它们强制被Focus
Not Done:
查看顶部属性的用途
0 0
- TextView跑马灯效果
- TextView跑马灯效果
- TextView跑马灯效果
- TextView跑马灯效果
- TextView跑马灯效果
- TextView跑马灯效果
- TextView 跑马灯效果
- TextView 跑马灯效果
- TextView跑马灯效果
- TextView跑马灯效果
- textview跑马灯效果
- textview跑马灯效果
- TextView跑马灯效果
- TextView跑马灯效果
- TextView跑马灯效果
- TextView跑马灯效果
- textview跑马灯效果
- TextView跑马灯效果
- Eclipse中Maven添加web项目
- 新手应该掌握的Linux命令
- 黑马程序员----数组
- NSFileManager
- Mysql的sql_mode设置
- TextView跑马灯效果
- 介绍两个很好用的jquery插件
- 【传递正能量】献给默默追梦的人
- 我是菜鸟:深入java容器内部
- 跟踪 Ring3 - Ring0 的执行流程
- C语言字符串、指针和内存问题总结
- win7_oracle11g_64位连接32位PLSQL_Developer
- MPLAB ICD3
- 判断链表是否有环及找到环的入口节点