MarqueeTextview(跑马灯)
来源:互联网 发布:电脑屏幕直播软件 免费 编辑:程序博客网 时间:2024/06/01 08:47
由于有时候TextView内容过长,实现跑马灯的状态,若一个Activity内只需一个TextView,可以为其添加以下属性
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
需要两个或多个,就要重新定义TextView类
public class MarqueeTextview extends TextView{public MarqueeTextview(Context context) {super(context);// TODO Auto-generated constructor stub}public MarqueeTextview(Context context, AttributeSet attrs, int defStyle) {super(context, attrs, defStyle);// TODO Auto-generated constructor stub}public MarqueeTextview(Context context, AttributeSet attrs) {super(context, attrs);// TODO Auto-generated constructor stub}@Overridepublic boolean isFocused() {// TODO Auto-generated method stubreturn true;}}
布局文件TextView标签用包名类目代替
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.xin.marqueetextview.MainActivity" > <com.example.xin.marqueetextview.MarqueeTextview android:id="@+id/tv_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:text="@string/hello_world" /> <com.example.xin.marqueetextview.MarqueeTextview android:layout_below="@+id/tv_1" android:id="@+id/tv_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:text="@string/hello_world" /></RelativeLayout>
0 0
- MarqueeTextview(跑马灯)
- 跑马灯效果自定义MarqueeTextView
- MarqueeTextView实现跑马灯效果
- android: 不需要焦点的TextView跑马灯 MarqueeTextView
- android: 不需要焦点的TextView跑马灯 MarqueeTextView
- android: 不需要焦点的TextView跑马灯 MarqueeTextView
- Flex “跑马灯”效果(自定义“跑马灯”控件)
- Flex “跑马灯”效果(自定义“跑马灯”控件)
- android跑马灯(xml)
- 跑马灯实现(转载)
- 跑马灯
- 跑马灯
- 跑马灯
- 跑马灯
- 跑马灯
- 跑马灯
- 跑马灯
- 跑马灯
- 响应式web设计之CSS3 Media Queries
- 聊聊移动端跨平台开发的各种技术
- leetcode之路009 Palindrome Number
- SQL SERVER学习杂记
- 学习笔记——mybatis的sql拼接与log4j调试
- MarqueeTextview(跑马灯)
- UIScrollView的属性总结
- hdu 1495 非常可乐(广搜)
- 7月份复习总结&8月份复习计划
- 随笔
- 设计模式(23) - 命令模式
- 五布局之表格布局TableLayout
- 设计模式(20) - 迭代器模式
- php传值赋值与引用赋值