Android开发 TextView实现跑马灯效果
2013-10-16 10:33
781 查看
第一种,运用TextView属性
android:ellipsize="marquee"----跑马灯
android:singleLine="true"----单行显示
android:focusable="true"----该textView适中获取焦点,只有获取焦点才能实现跑马灯效果,如果是多个TextView列表需要把这个属性去掉才能实现点击那个view那个view跑
android:marqueeRepeatLimit="marquee_forever"----一直循环跑
android:focusableInTouchMode="true"----必须有
第二种,重写TextView类,可以实现多个TextView同时实现跑马灯效果
布局文件中使用
<TextView style="@style/show_cost_red_txt" android:layout_toRightOf="@id/dao" android:text="@string/show_nan" android:id="@+id/end_point" android:singleLine="true" android:ellipsize="marquee" android:focusable="true" android:marqueeRepeatLimit="marquee_forever" android:focusableInTouchMode="true" />
android:ellipsize="marquee"----跑马灯
android:singleLine="true"----单行显示
android:focusable="true"----该textView适中获取焦点,只有获取焦点才能实现跑马灯效果,如果是多个TextView列表需要把这个属性去掉才能实现点击那个view那个view跑
android:marqueeRepeatLimit="marquee_forever"----一直循环跑
android:focusableInTouchMode="true"----必须有
第二种,重写TextView类,可以实现多个TextView同时实现跑马灯效果
package com.online.bchd.jsk.view; /** * @author * @time
* @info 重写textview实现字符过长的跑马灯效果*/ import android.content.Context; import android.util.AttributeSet; import android.widget.TextView; public class MForeverTextView extends TextView { public MForeverTextView(Context context) { super(context); } public MForeverTextView(Context context, AttributeSet attrs) { super(context, attrs); } public MForeverTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public boolean isFocused() { return true; } }
布局文件中使用
<com.online.bchd.jsk.view.MForeverTextView style="@style/show_cost_red_txt" android:id="@+id/start_point" android:text="@string/show_dong" android:singleLine="true" android:ellipsize="marquee" />
相关文章推荐
- Android开发:TextView实现跑马灯效果
- Android开发实现TextView跑马灯效果
- Android开发 第三课 使用TextView实现跑马灯效果
- Android开发之TextView实现跑马灯效果
- Android开发实现TextView跑马灯效果
- Android TextView实现跑马灯效果的方法
- Android使用TextView实现跑马灯效果
- Android TextView实现跑马灯效果。
- Android实现多个TextView同时显示跑马灯效果
- Android入门(3)——使用TextView实现跑马灯效果
- android开发之——设置TextView文本为跑马灯效果
- Android TextView 跑马灯效果的实现
- Android中TextView不获取焦点可以实现跑马灯的效果
- How:android开发中实现TextView垂直滚屏效果的方法
- android TextView实现跑马灯效果
- android使用TextView实现文字的跑马灯效果
- 一、Android 实现两个TextView跑马灯效果
- Android TextView实现跑马灯效果
- Android之TextView内容实现跑马灯效果
- Android常用UI编程_TextView实现跑马灯效果