android在Gridview实现Textview跑马灯效果
16lz
2021-12-04
默认是下面的属性添加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);}@Overridepublic boolean isFocused(){return true;}}使用上面自定义的TextView并且去掉android:focusable="true" 即可。
更多相关文章
- Android下实现一个Activity的全屏显示
- 2019-08-20 app常用模块布局之viewpager和fragment
- 十六、Android(安卓)滑动效果汇总
- Android(安卓)滑动效果汇总
- 50个Android开发人员必备UI效果源码
- 50个Android开发人员必备UI效果源码
- 50个Android开发人员必备UI效果源码
- 50个Android开发人员必备UI效果源码
- 50个Android开发人员必备UI效果源码