<TextView
android:id="@+id/game_info_gname"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:ellipsize="marquee"
android:singleLine="true"
android:textSize="15sp"
android:textStyle="bold" />
如果TextView跑马灯效果没有实现的童鞋,注意一下 android:focusable="true" android:focusableInTouchMode="true"
加上这两个属性然后TextView有了华丽丽的跑马灯效果,但是当你兴冲冲的把他加入到GridView中,你会发现,不仅跑马灯效果没有了,而且因为设置了android:focusable属性,会让GridView没法点击了。下边是解决办法:其实很简单:重写TextView的isFocused方法
public class mTextView extends TextView {
//构造方法了
......
......
public boolean isFocused() {
return true;
}
}
然后把这个TextView 扔到你的GridView 的item中
<org.cs.views.mTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:ellipsize="marquee"
android:singleLine="true"
android:scrollHorizontally="true"
android:textSize="15sp"
android:textStyle="bold"
/>
就OK了
话说这个问题折腾了好久..