I have created a custom class AlwaysMarqueTextView
public class AlwaysMarqueeTextView extends TextView
{
protected boolean a;
public AlwaysMarqueeTextView(Context context)
{
super(context);
a = false;
}
public AlwaysMarqueeTextView(Context context, AttributeSet attributeset)
{
super(context, attributeset);
a = false;
}
public AlwaysMarqueeTextView(Context context, AttributeSet attributeset, int i)
{
super(context, attributeset, i);
a = false;
}
public boolean isFocused()
{
return a || super.isFocused();
}
public void setAlwaysMarquee(boolean flag)
{
setSelected(flag);
setSingleLine(flag);
if(flag)
setEllipsize(TruncateAt.MARQUEE);
a = flag;
}
@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);
}
}
And you can startMarquee when desire.. like
//textView.setSelected(true); No need of Selection..
textview.setAlwaysMarquee(true);