TextView实现跑马灯效果
来源:互联网 发布:dk9000效果器调音软件 编辑:程序博客网 时间:2024/05/08 18:28
1)、TextView实现跑马灯效果
第一步:在textview控件中添加一下四个属性:
android:ellipsize="marquee"
android:singleLine="true"
android:focusable="true"
android:focusableInTouchMode="true"
第二步:新建一个java类,实现其isFocused方法:
package com.example.firstproject;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;
public class MarqueeText extends TextView{
@SuppressLint("NewApi")
public MarqueeText(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
// TODO Auto-generated constructor stub
}
public MarqueeText(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
// TODO Auto-generated constructor stubs
}
public MarqueeText(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public MarqueeText(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public boolean isFocused(){
return true;
}
}
第三步:引用包名:
<com.example.firstproject.MarqueeText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:singleLine="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="@string/hello_world" />
第一步:在textview控件中添加一下四个属性:
android:ellipsize="marquee"
android:singleLine="true"
android:focusable="true"
android:focusableInTouchMode="true"
第二步:新建一个java类,实现其isFocused方法:
package com.example.firstproject;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;
public class MarqueeText extends TextView{
@SuppressLint("NewApi")
public MarqueeText(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
// TODO Auto-generated constructor stub
}
public MarqueeText(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
// TODO Auto-generated constructor stubs
}
public MarqueeText(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public MarqueeText(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public boolean isFocused(){
return true;
}
}
第三步:引用包名:
<com.example.firstproject.MarqueeText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:singleLine="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="@string/hello_world" />
0 0
- TextView实现跑马灯效果
- TextView实现跑马灯效果
- TextView实现跑马灯效果
- TextView实现跑马灯效果
- TextView实现跑马灯效果
- TextView实现跑马灯效果
- TextView实现跑马灯效果
- TextView实现跑马灯效果
- TextView实现跑马灯效果
- textview实现跑马灯效果
- TextView实现跑马灯效果
- TextView实现跑马灯效果
- TextView 实现跑马灯效果
- TextView 实现跑马灯效果
- TextView实现跑马灯效果
- textView跑马灯效果实现
- TextView实现跑马灯效果
- textview实现跑马灯效果
- 基于spring mvc的ajax异步上传文件
- Java设计模式----桥梁模式
- linux socket server and client
- HashMap<K, V>泛型类
- linux的rpm与yum命令的使用
- TextView实现跑马灯效果
- 大家好。我的contiki之旅开始啦
- Spring 3整合Quartz 2实现定时任务一:常规整合
- poj 3292 Semi-prime H-numbers 筛数打表
- ArcGIS Engine不同格式数据打开,对象创建,导入导出
- 电话拨号器
- 词法作用域与动态作用域的区别
- shell实例浅谈之十四利用crontab自动清除日志
- 不能在析构函数里面抛出异常