tags:

views:

874

answers:

3

How can I use marquee text in an android application?

+5  A: 

android:ellipsize="marquee"

This only works when your TextView has the focus.

Maurits Rijk
It also works when the TextView is selected.
Romain Guy
thanks ...can u give me a example please?
RBADS
He just did. You set `android:ellipsize="marquee"` on your `TextView`. It's all documented on developer.android.com by the way.
Matthias
A: 

Here is an example:

public class TextViewMarquee extends Activity {
    private TextView tv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        tv = (TextView) this.findViewById(R.id.tv);  
        tv.setSelected(true);  // Set focus to the textview
    }
}

The xml file with the textview:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView
        android:id="@+id/mywidget"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:lines="1"
        android:ellipsize="marquee"
        android:fadingEdge="horizontal"
        android:marqueeRepeatLimit="marquee_forever"
        android:scrollHorizontally="true"
        android:textColor="#ff4500"
        android:text="Simple application that shows how to use marquee, with a long text" />
</RelativeLayout>
droidgren
A: 

And is there a way to do it from the class java : by example:

TextView text = (TextView)findViewById(R.id.text); test.setEllipsize(where);

what is the "where"?

Tsunaze