Android 跑马灯
Android 跑马灯
跑马灯的效果,我看到好多文章就想笑。很多文章都有一句,文字不能比TextView长。我了个去,有点脑子的都知道,文字没有TextView长的话还需要跑马吗?全显示出来了还需要跑马?
跑马灯的效果默认是需要获得焦点才有效。为了任何时候有效,可以继承Textiew,重写IsFocused方法,返回true。
本文工程源码下载:
免费下载地址在 http://linux.bkjia.com/
用户名与密码都是www.bkjia.com
具体下载目录在 /pub/Android源码集锦/2011年/12月/Android 跑马灯/
- public class MarqueeTextView extends TextView {
- public MarqueeTextView(Context context) {
- super(context);
- }
- public MarqueeTextView(Context context, AttributeSet attrs){
- super(context,attrs);
- }
- public MarqueeTextView(Context context, AttributeSet attrs, int defStyle){
- super(context, attrs, defStyle);
- }
- public boolean isFocused(){
- return true;
- }
- }
- mText.setSingleLine(true);
- mText.setEllipsize(TruncateAt.MARQUEE);
- mText.setMarqueeRepeatLimit(-1);
评论暂时关闭