使用TextView实现跑马灯效果
2016-08-01 10:11
399 查看
使用TextView实现跑马灯效果
分为几个步骤,一、首先设置layout文件
<TextView android:id="@+id/text_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:text="@string/hello_world"/>
加入singleLine,ellipsize = marquee,focusable,focusableInTouchMode = “true”。这样就可以实现了跑马灯效果
随后再加入一个TextView后,只有第一个TextView存在跑马灯效果,所以要用Focu强制转一下
方法如下:
二、新建一个class文件,继承TextView,加入其中三个构造器。
随后复写一个isFocused()。
public class MarqueeTest extends TextView { public MarqueeTest(Context context) { super(context); } public MarqueeTest(Context context, AttributeSet attrs) { super(context, attrs); } public MarqueeTest(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Override public boolean isFocused() { return true; } }
最后一把,在Layout中,将TextView的
<TextView———>替换为:
<com.yourname.clicklinstener.MarqueeTest
相关文章推荐
- Android控件笔记——使用TextView实现跑马灯效果
- android使用TextView实现文字的跑马灯效果
- 使用TextView实现跑马灯效果
- 使用TextView实现跑马灯的效果
- 使用TextView实现跑马灯效果
- Android 高级UI设计笔记05:使用TextView实现跑马灯的效果
- 使用TextView可以实现跑马灯效果
- 使用TextView实现跑马灯效果
- Android使用TextView实现跑马灯效果
- 使用TextView实现跑马灯效果
- 使用TextView实现跑马灯的效果
- Android入门(3)——使用TextView实现跑马灯效果
- Android开发 第三课 使用TextView实现跑马灯效果
- 论TextView的超链接使用、显示表情、Html语法支持、跑马灯效果的实现
- 安卓控件使用系列4:TextView实现跑马灯效果
- 使用TextView实现跑马灯效果
- 使用TextView实现跑马灯效果
- Android中使用TextView实现文字跑马灯效果
- Android使用TextView实现跑马灯效果
- TextView实现跑马灯效果