android 跑马灯实现
来源:互联网 发布:程序员接活网 编辑:程序博客网 时间:2024/04/29 18:17
必须设置这2个,否则没效果!
android:singleLine="true"
android:focusableInTouchMode="true"
网上有的根本不能实现效果。莫非和版本有关?
另外:可参考http://www.eoeandroid.com/forum.php?mod=viewthread&tid=165922&reltid=183394&pre_thread_id=0&pre_pos=2&ext=
(文本框内容文本的“跑马灯”效果在有些地方很有用。通过搜索学习,附件的源码把“跑马灯”的几种做法归纳在一起,供大家参考!!!!!!)
下面是我的简单实现
XML定义:
默认的TextView
<TextView
android:id="@+id/marqueebyxml"
android:layout_width="5dip"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:layout_marginLeft="10dip"
android:focusableInTouchMode="true"
android:text="这是通过XML文件设置的效果!" />
自定义:
<com.wletv.MarqueeText
android:id="@+id/AMTV1"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_marginLeft="80dip"
android:textSize="25sp"
android:textColor="@android:color/black"
android:lines="1"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
android:marqueeRepeatLimit="marquee_forever"
android:ellipsize="marquee"
android:background="#2FFFFFFF"
android:singleLine="true"
android:text="这才是真正的文字跑马灯效果,文字移动速度,文字移动方向,文字移动的样式,动画等等……"
/>
package com.wletv;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.TextView;
public class MarqueeText extends TextView {
public MarqueeText(Context con) {
super(con);
}
public MarqueeText(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MarqueeText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean isFocused() {
return true;
}
@Override
protected void onFocusChanged(boolean focused, int direction,
Rect previouslyFocusedRect) {
}
}
- android跑马灯实现
- android 跑马灯实现
- Android跑马灯实现
- Android跑马灯实现
- android实现跑马灯效果
- android实现跑马灯效果
- android--TextView实现跑马灯
- Android跑马灯效果实现
- android 实现跑马灯效果
- Android 跑马灯效果实现
- android实现跑马灯效果
- Android跑马灯的实现
- android跑马灯效果实现
- Android实现跑马灯效果
- Android跑马灯效果实现
- android实现跑马灯效果
- Android TextView实现跑马灯
- Android实现跑马灯效果
- 下载,编译hadoop 代码
- OpenCV访问图像像素值的若干种方式
- I2C 驱动开发 实例
- matlab 支持向量机libSVM 使用
- nefu 482 方格取数问题 二分图最大点权独立集
- android 跑马灯实现
- 如何用万用表识别三极管的管型和管脚
- 听说没有房产在广州也可以成为广州人哦?
- python:map filter reduce
- 从键盘输入10个学生的姓名和成绩,按字典序排列学生的姓名并输出(姓名和成绩对应关系保持不变)
- 国企如何发展自己的信息化队伍
- CUDA程序如何解决 warning C4819?
- stirling数的性质及应用
- PHP模板之Smarty安装与使用入门教程