首页 > 代码库 > TextView不用获取焦点也能实现跑马灯
TextView不用获取焦点也能实现跑马灯
public class MarqueeTextView extends TextView {
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
if(focused)
super.onFocusChanged(focused, direction, previouslyFocusedRect);
}
@Override
public void onWindowFocusChanged(boolean focused) {
if(focused)
super.onWindowFocusChanged(focused);
}
@Override
public boolean isFocused() {
return true;
}
}
android:singleLine="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:ellipsize="marquee"
android:scrollHorizontally="true"
android:marqueeRepeatLimit="marquee_forever"
这里解决了:1、下拉状态栏到半截不松开时和失去焦点时显示"......"的问题
2、失去焦点不滚动问题。
原文地址:http://blog.csdn.net/wangjia55/article/details/7867437
TextView不用获取焦点也能实现跑马灯