Dileep Perla
Dileep Perla

Reputation: 1865

Android: TextView is not scrolling Automatically

I have a TextView with following attributes :

<TextView
        android:id="@+id/appheader" 
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_centerVertical="true"
        android:textColor="#ffffff"
        android:layout_marginLeft="3dp"
        android:textSize="21sp"
        android:singleLine="true"
        android:ellipsize="marquee"
        android:marqueeRepeatLimit="marquee_forever"
        android:scrollHorizontally="true"
        android:focusable="true"
        android:focusableInTouchMode="true"/> 

Actually the TextView scrolls ONLY when I click the TextView. But I want to scroll it automatically when I launch the Activity. How can I do this ?

Upvotes: 1

Views: 3199

Answers (3)

Puneet Akhouri
Puneet Akhouri

Reputation: 41

set android:scrollHorizontally="true" for that textview.

Also set the following two properties:

text.setMovementMethod(new ScrollingMovementMethod());

text.setSelected(true);

Upvotes: 1

vtuhtan
vtuhtan

Reputation: 1066

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="very long text to srollll dkfjadkfjkldjfkjdkghjhtudhfjhdjfkdfkadjsajekdfjak" 
    android:singleLine="true" 
    android:marqueeRepeatLimit="marquee_forever" 
    android:ellipsize="marquee"
    android:focusable="true" 
    android:focusableInTouchMode="true"/>

Upvotes: 2

orchidrudra
orchidrudra

Reputation: 1182

By-default TextView marquee effect works when it get focus. To make an automatic marquee effect you need to extend TextView class. See this link for reference.

Upvotes: 1

Related Questions