Reputation: 3936
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?
Upvotes: 4
Views: 5208
Reputation: 966
Other then what is mentioned above you also need to add
txtView.setSelected(true)
worked for me adding this line
Upvotes: 1
Reputation: 4235
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.)
Upvotes: 10