public class MarqueeTextView extends TextView {
public MarqueeTextView(Context appCon) {
super(appCon);
}
public MarqueeTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MarqueeTextView(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) {
}
}
下面就是如何使用跑马灯的XML
<com.lta.mytransport.ui.utils.MarqueeTextView android:id="@+id/floodMsgView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="marquee"
android:singleLine="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:freezesText="true"
android:scrollHorizontally="true"
android:text="@string/floodMsgDemo"
android:marqueeRepeatLimit="marquee_forever"/>