curiousguy
curiousguy

Reputation: 609

Marquee text not working in widget

Here is the situation, i have a widget containing two text views and i want the text to scroll if its width exceeds the layout width. The problem is that, the marquee is working for bottom text view but its not working for the upper one. I am attaching the code snippet. Can you tell me what i am doing wrong?

<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/left"
        android:layout_width="97dip"
        android:layout_height="fill_parent" >

        <TextView
            android:id="@+id/place"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dip"
            android:ellipsize="marquee"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:lines="1"
            android:marqueeRepeatLimit="marquee_forever"
            android:scrollHorizontally="true"
            android:textColor="@color/white" >
        </TextView>

        <TextView
            android:id="@+id/weather_report"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/place"
            android:ellipsize="marquee"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:lines="1"
            android:marqueeRepeatLimit="marquee_forever"
            android:scrollHorizontally="true"
            android:textColor="@color/grey" >
        </TextView>
    </RelativeLayout>

Upvotes: 4

Views: 1449

Answers (2)

Pradeep Sodhi
Pradeep Sodhi

Reputation: 2145

Use android:scrollbars = "horizontal" in the textview of your xml file. In java code use:

textview.setMovementMethod(new ScrollingMovementMethod());

Upvotes: 0

Talha
Talha

Reputation: 66

try this, works for me:

<TextView 
    android:id="@+id/fact" 
    android:layout_width="200dp"
    android:text="Loading... More text to see if it spans or not and want more"
    android:singleLine="true" 
    android:ellipsize="marquee"
    android:marqueeRepeatLimit ="marquee_forever"
    android:scrollHorizontally="true"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:duplicateParentState="true">
   <requestFocus 
      android:focusable="true" 
      android:focusableInTouchMode="true"
      android:duplicateParentState="true" />
</TextView>

Upvotes: 4

Related Questions