多个TextView跑马灯效果实现
来源:互联网 发布:java命令行参数args 编辑:程序博客网 时间:2024/05/01 18:48
显示跑马灯效果的前提条件就是你的文本内容要比显示文本的外部组件长,即外部组件无法完整的显示内部的文本内容
activity_main.xml
//两个TextView
<com.example.textview.marqueeTextView (原本的TextView改为包名.类名)
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<com.example.textview.marqueeTextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:layout_marginTop="10dp"
android:layout_below="@+id/textView2"
android:text="@string/hello_world2" />
android:singleLine 表示使用单行文字
android:marqueeRepeatLimit,设置走马灯滚动的次数。
android:ellipsize,设置了文字过长时如何切断文字, 如果使用走马灯效果则设为marquee.
android:focusable,Android的缺省行为是在控件获得Focus时才会显示走马灯效果
新建一个marqueeTextView.java类,继承TextView类。添加TextView的三个构造函数,使用isFocused方法实现滚动。
marqueeTextView.java
public class marqueeTextView extends TextView{
public marqueeTextView(Context context) {
super(context);
}
public marqueeTextView(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
}
public marqueeTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean isFocused() {
return true;
}
}
- 多个TextView实现跑马灯效果
- 多个TextView跑马灯效果实现
- Android实现多个TextView同时显示跑马灯效果
- Android实现多个TextView同时显示跑马灯效果
- Android实现多个TextView同时显示跑马灯效果
- Android实现多个TextView同时显示跑马灯效果
- Android-多个TextView实现跑马灯效果
- Android实现多个跑马灯效果,多个文本框TextView的跑马灯
- Android实现多个跑马灯效果,多个文本框TextView的跑马灯
- 多个TextView跑马灯效果
- 多个TextView 跑马灯效果
- TextView实现跑马灯效果
- TextView实现跑马灯效果
- TextView实现跑马灯效果
- TextView实现跑马灯效果
- TextView实现跑马灯效果
- TextView实现跑马灯效果
- TextView实现跑马灯效果
- C++实现voronoi图
- CoordinateLayout框架初步总结(未完)
- failover与ActiveMQ的jms.prefetchPolicy.queuePrefetch以及wireFormat.maxInactivityDura
- 联调 我不怕!(二)
- 2015百度产品笔试题(全)(无答案)
- 多个TextView跑马灯效果实现
- activemq 重新连接的机制
- activeMQ的源码分析 -TCP通讯机制
- Software caused connection abort: recv failed
- sqlite3树形结构遍历效率对比测试
- 使用httpclient、htmlcleaner 、xpath 采集新浪微博3G站点数据
- JVM 优化经验总结
- HttpClient 模拟登录手机版新浪微博
- ImageView.ScaleType设置图解