Android的自定义TextView实现跑马灯效果
来源:互联网 发布:传单制作软件 编辑:程序博客网 时间:2024/04/30 01:53
今天我要实现跑马灯效果,灯饰直接在TextView上设置属性是实现不了的,必须自定义TextView。
下面这个是自定义的TextView,然后重写isFocused(),返回true。
public class CustomTextView extends TextView{ public CustomTextView(Context context) { super(context); } public CustomTextView(Context context, AttributeSet attrs) { super(context, attrs); } public CustomTextView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Override public boolean isFocused() { return true; }}
然后在布局中写布局,但是要注意,Text的内容必须大于TextView的长度才能实现跑马灯的效果
android:ellipsize = “end” 省略号在结尾
android:ellipsize = “start” 省略号在开头
android:ellipsize = “middle” 省略号在中间
android:ellipsize = “marquee” 跑马灯
android:scrollHorizontally=”true”相信大家英文水平还不错的话都明白这句的意思是水平滚动
android:marqueeRepeatLimit=”marquee_forever” 看英文同样可以明白,是无限次循环,学习android,英文基础还是必须的。
android:focusable=”true” //让TextView获得焦点
android:focusableInTouchMode=”true” //针对触摸屏获得当前焦点
事实上这两句代码我也了解不是特别多,在网上查了下这两个属性,目前理解为:
android:focusable=”true”相当于当前Activity打开的时候,让当前控件TextView获得焦点,才可以实现滚动功能
android:focusableInTouchMode=”true”和上述属性应该是类似的,但限制应该是指的触摸屏上的意思
对于这两个属性,希望有高人指点下。
<com.yaodan.shaketerrace.view.CustomTextView android:id="@+id/tv_msg" android:layout_width="match_parent" android:layout_height="0dp" android:ellipsize="marquee" android:scrollHorizontally="true" android:marqueeRepeatLimit="marquee_forever" android:layout_weight="1" android:gravity="center" android:background="#e0484a" android:textColor="#ffffff" android:text="用户1393566**** 获得彩票一张 跑马灯 跑马灯跑马灯跑马灯跑马灯跑马灯跑马灯跑马灯跑马灯跑马灯跑马灯跑马灯"/>
- Android自定义TextView实现跑马灯效果
- Android 自定义textview实现跑马灯效果
- android自定义的TextView,实现跑马灯效果
- Android的自定义TextView实现跑马灯效果
- Android TextView 跑马灯效果的实现
- Android实现跑马灯效果的TextView
- 自定义TextView实现跑马灯效果
- 自定义TextView实现跑马灯效果
- 自定义TextView实现跑马灯效果
- 自定义TextView实现跑马灯效果
- android 自定义textview跑马灯效果
- Android 自定义控件:垂直滚动的TextView实现竖向跑马灯效果
- Android自定义不需要焦点的TextView以实现跑马灯效果
- android TextView的跑马灯效果的实现
- Android TextView跑马灯效果实现
- android textview跑马灯效果实现
- Android TextView实现跑马灯效果
- android TextView实现跑马灯效果
- 《卡尔曼滤波原理及应用-MATLAB仿真》程序-3.5.1
- 1045. 快速排序(25)
- 常用ADB操作
- Linux下设置静态Ip
- Android源码分析-----带你认识不一样的AsyncTask 详解
- Android的自定义TextView实现跑马灯效果
- 节约内存-Redis
- C语言产生随机数
- leetcode 203. Remove Linked List Elements
- 错排公式-计数
- hibernate操作数据库
- iOS开发--利用 runtime,解决多次点击相同 button,导致重复跳转的问题
- hdu2099整除的尾数
- centOS安装telnet(在线和rpm包安装)