GridView 中TextView的跑马灯效果

<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了
话说这个问题折腾了好久..
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值