android TextView实现跑马灯效果
2015-02-03 09:22
585 查看
首先新建一个项目
在Layout布局中 吧TextView的属性设置为:
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
但是在复杂的布局中,只能第一个实现,如果有第二个TextView则实现不了跑马灯的效果
所以我们需要进一步修改一下:
在src新建一个类,我们可以命名为marqueeTextView
1、让继承TextView
2、导入TextView的三个方法 这里有一个小技巧:鼠标右键 选择Source 然后点击Generate Constructors from Superclass 然后点击OK即把所以的方法都加进去了。
3、然后再加入 public boolean isFocused() {
// TODO Auto-generated method stub
return true;
}
的方法。
4、在返回Layout布局中 把<TextView />改为<com.example.marqueetextview.MarqueeTextView />
5、这样所有的TextView都可实现跑马灯的效果。
大家可以查看我的小网站:我的网站 www.sfyblog.com
在Layout布局中 吧TextView的属性设置为:
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
但是在复杂的布局中,只能第一个实现,如果有第二个TextView则实现不了跑马灯的效果
所以我们需要进一步修改一下:
在src新建一个类,我们可以命名为marqueeTextView
1、让继承TextView
2、导入TextView的三个方法 这里有一个小技巧:鼠标右键 选择Source 然后点击Generate Constructors from Superclass 然后点击OK即把所以的方法都加进去了。
3、然后再加入 public boolean isFocused() {
// TODO Auto-generated method stub
return true;
}
的方法。
4、在返回Layout布局中 把<TextView />改为<com.example.marqueetextview.MarqueeTextView />
5、这样所有的TextView都可实现跑马灯的效果。
大家可以查看我的小网站:我的网站 www.sfyblog.com
相关文章推荐
- android用TextView实现跑马灯效果
- android TextView实现实现跑马灯效果,并监听滚动完成动作。
- Android TextView属性及跑马灯效果的实现
- Android中TextView实现垂直滚动(轮换效果,非跑马灯)
- Android常用UI编程_TextView实现跑马灯效果
- TextView属性android:ellipsize实现跑马灯效果,TextView内容过长加省略号,点击显示全部内容
- Android之TextView内容实现跑马灯效果
- Android--TextView实现跑马灯效果
- Android TextView实现跑马灯效果
- Android实现多个跑马灯效果,多个文本框TextView的跑马灯
- android用TextView实现跑马灯效果
- Android实现多个TextView同时显示跑马灯效果
- android TextView的跑马灯效果的实现
- android TextView实现跑马灯效果
- Android开发 TextView实现跑马灯效果
- Android TextView实现跑马灯效果
- Android实现多个跑马灯效果,多个文本框TextView的跑马灯
- android在Gridview实现Textview跑马灯效果
- Android开发:TextView实现跑马灯效果
- android TextView不用获得焦点实现跑马灯效果 两种方法