用代码简单的实现跑马灯效果
来源:互联网 发布:java缩小图片尺寸 编辑:程序博客网 时间:2024/05/22 17:30
在res资源文件夹下的layout中定义一个TextView控件代码如下:
<TextView android:text="@string/hehe" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" />
其中string中是你实现效果的文字。这样就可以实现你的跑马灯效果了。
如果想要同时实现两个跑马灯效果,需要你重新定义一个类来继承TextView然后重写它的三个方法,最后需要在重载他的一个isFocused方法,让它return true;
.最后一步就是,用我们自定义的这个类(com.imooc.包名.类名)来替代textview.如下:
<com.example.android_06_demo.MyclassTextView android:text="@string/hehe" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" /> <com.example.android_06_demo.MyclassTextView android:text="@string/hehe" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" />这样就可以同时实现两个跑马灯的效果了。
0 0
- 用代码简单的实现跑马灯效果
- 简单实现跑马灯效果
- 简单的跑马灯效果
- 简单的跑马灯效果
- TextView简单实现跑马灯效果
- Silverlight跑马灯效果实现代码
- 用最简单的方法实现ViewPager无限循环滑动(跑马灯)效果
- 用TextView实现跑马灯效果(很简单,很流弊的方法)
- html简单的跑马灯效果
- 跑马灯效果的两种实现
- WinForm中实现跑马灯的效果
- XML 实现 TextView的跑马灯效果
- Android TextView 跑马灯效果的实现
- TextView实现跑马灯的效果
- TextView实现跑马灯的效果
- 实现文字的跑马灯效果,Textview
- Android实现跑马灯效果的TextView
- 使用TextView实现跑马灯的效果
- 保证数据完整性
- Java-Android开发环境搭建
- enum实战之石头剪刀布
- 保证数据完整性1
- Set集合
- 用代码简单的实现跑马灯效果
- android studio 自动生成R文件影响编译的解决方法
- eclipse学习心得
- 虚拟继承
- 【南理oj】12 - 喷水装置(二)(贪心,好题)
- Python进行科学计算
- iOS之调用系统自带语音功能
- Quaternion 四元数
- Eclipse中部署tomcat web service 生成jsp dynamic web page