Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

marquee text view animation

Tags:

android

The marquee animation does not work, this is what I did.

<LinearLayout android:layout_height="wrap_content"
            android:layout_width="wrap_content" android:background="@drawable/bg_trans"
            android:layout_alignParentBottom="true" android:orientation="vertical">

            <TextView android:id="@+id/trackName"
            android:layout_height="wrap_content" android:layout_width="wrap_content"                
            android:textColor="@android:color/white" android:textSize="18sp"
            android:maxLines="2" android:ellipsize="marquee"
            android:scrollHorizontally="true" 
            android:focusable="true" android:focusableInTouchMode="true"
            android:marqueeRepeatLimit="marquee_forever"
            android:layout_gravity="center_horizontal" />

            <TextView android:id="@+id/artistName" 
            android:layout_height="wrap_content" android:layout_width="wrap_content"                
            android:textColor="@android:color/white" android:textSize="18sp"
            android:maxLines="2" android:ellipsize="marquee"
            android:scrollHorizontally="true" 
            android:focusable="true" android:focusableInTouchMode="true"
            android:marqueeRepeatLimit="marquee_forever"
            android:layout_gravity="center_horizontal" />
            </LinearLayout>

It works for the first textview but doens't work for the second. What am I doing wrong?

like image 449
Hades Avatar asked Dec 22 '22 11:12

Hades


1 Answers

This works for me -

<TextView 
android:id="@+id/capture_mode"
android:layout_width="200px"
android:layout_height="wrap_content"           
android:text="This is a test of marquee on the text view in android."
android:ellipsize="marquee"
android:scrollHorizontally="true"
android:singleLine="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
/>

The field marqueeRepeatLimit will set the number of repitions.

UPDATE: The width of the text view need to be hardcoded to a specific value, you can set it to wrap_content. In such cases the marquee will still work just that it will have some blank space after the end the text and before it starts to display the text again. (Think Digital signboards, they have some gap in the display before displaying the next item.)

like image 137
bluefalcon Avatar answered Jan 05 '23 05:01

bluefalcon