MarqueeTextView for Android

Layout

<TextView  
        android:layout_width="56dp"  
        android:layout_height="wrap_content"  
        android:ellipsize="marquee"  
        android:focusable="true"  
        android:focusableInTouchMode="true"  
        android:marqueeRepeatLimit="marquee_forever"  
        android:singleLine="true"  
        android:text="Android TextView marquee test text"/>

Custom TextView

public class MarqueeTextView extends TextView {  
  
    public MarqueeTextView(Context context) {  
        super(context);  
        initView();  
    }  
  
    public MarqueeTextView(Context context, AttributeSet attrs) {  
        super(context, attrs);  
        initView();  
    }  
  
    public MarqueeTextView(Context context, AttributeSet attrs, int defStyle) {  
        super(context, attrs, defStyle);  
        initView();  
    }  
  
    private void initView() {  
        setEllipsize(TruncateAt.MARQUEE);  
        setMarqueeRepeatLimit(-1);  
        setFocusableInTouchMode(true);  
    }  
  
    @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;  
    }  
}