android在Gridview实现Textview跑马灯效果
2014-04-29 15:56
751 查看
默认是下面的属性添加TextView中: android:ellipsize="marquee" android:focusableInTouchMode="true" android:gravity="center" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:singleLine="true"但是你会发现无效,并且gridview也不可点击,只有自定义Textview代码如下:
package com.shangc.mycar.custom; import android.content.Context; import android.util.AttributeSet; import android.widget.TextView; /** * 自定义textview实现在GridView实现跑马灯的效果,复写view里面的isFocused()方法,默认情况下是不会有效果的, * 而且gridview也不可点击 * * @author dennis * */ public class MyGridViewTextView extends TextView { public MyGridViewTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // TODO Auto-generated constructor stub } public MyGridViewTextView(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean isFocused() { return true; } } 使用上面自定义的TextView并且去掉android:focusable="true" 即可。
相关文章推荐
- Android基于TextView不获取焦点实现跑马灯效果
- Android-TextView跑马灯效果实现与分析
- Android中TextView实现的“跑马灯”效果
- Android中继承TextView实现文字的跑马灯效果
- Android TextView实现跑马灯效果
- Android——TextView实现跑马灯效果
- Android自定义TextView实现跑马灯效果
- android TextView实现跑马灯效果
- Android中TextView实现垂直滚动(轮换效果,非跑马灯)
- android TextView的跑马灯效果的实现
- Android中TextView不获取焦点可以实现跑马灯的效果
- Android TextView实现垂直滚动的跑马灯效果
- Android TextView实现跑马灯效果。
- Android TextView实现跑马灯效果
- android TextView实现跑马灯效果
- android textView实现跑马灯效果
- Android TextView 实现跑马灯效果
- Android实现TextView跑马灯效果
- Android---14---TextView实现跑马灯效果
- Android中长TextView实现跑马灯效果