android textView跑马灯效果
来源:互联网 发布:小众手表 知乎 编辑:程序博客网 时间:2024/04/30 12:40
较长的文字不能换行显示,需要跑马灯效果
方法一:在XML文件中设置属性
注意maxlLines = “1”和singleLine=”true”的区别前者会将多余部分截去换到下一行显示,而后者是将内容全部放到一行只是屏幕无法显示而已所以此处应为后者。同理此处不能设置宽度为匹配父控件
做法:
1. 自定义控件
public class MarqueeText extends TextView { public MarqueeText(Context context) { super(context); } public MarqueeText(Context context, AttributeSet attrs) { super(context, attrs); } public MarqueeText(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @Override public boolean isFocused() { return true;//此处使得文本一直获得焦点 } @Override protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { //此处是为了防止焦点改变而效果消失 }}
- 应用自定义控件
<com.example.textviewsample.MarqueeText android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/text" android:id="@+id/text_view1" android:ellipsize="marquee" android:singLine = "true" android:focusable="true" android:focusableInTouchMode="true" android:marqueeRepeatLimit="marquee_forever"/> //使跑马灯一直不停
0 0
- Android TextView跑马灯效果
- Android TextView跑马灯效果
- Android TextView跑马灯效果
- Android TextView跑马灯效果
- [Android]TextView跑马灯效果
- Android textView 跑马灯效果
- android TextView 跑马灯效果
- Android TextView跑马灯效果
- Android TextView跑马灯效果
- Android TextView跑马灯效果
- android TextView跑马灯效果
- android TextView跑马灯效果
- Android TextView跑马灯效果
- Android TextView跑马灯效果
- android textView跑马灯效果
- Android TextView 跑马灯效果
- Android TextView跑马灯效果
- android textview 跑马灯效果
- Servlet上传到mysql数据库中文乱码问题
- ACM专题四1001
- android 7.1 学习计划
- 内网打洞以及代码实现
- Spring MVC拦截器+注解方式实现防止表单重复提交
- android textView跑马灯效果
- 【Android开发】TextSwitcher 使用详解
- OPENCV连通域操作
- 图形学数学变换的领悟-持续更新
- 九度OJ 1023
- Android greenDAO 使用案例解析
- double frequency=cv::getTickFrequency(); const int64 start=cv::getTickCount();
- 标题头
- linux下安装部署jdk7+tomcat环境