Mark not scrolling in android

I want to use the marquee function in my Android application and use this code to achieve the goal:

<TextView android:id="@+id/marqueetext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="marquee" android:fadingEdge="horizontal" android:lines="1" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:text="hello all how are you" android:textColor="#ff4500" /> MarqueeText = (TextView)ShowTheMessages.this.findViewById(R.id.marqueetext); MarqueeText.setSelected(true); 

I do not know why it does not work. I went through many related posts, but did not find a solution. Please help me. Thanks in advance.

+4
source share
3 answers

change this line and try ...

 android:text="hello all how are you hello all how are you hello all how are you hello all how are you" TextView txtView=(TextView) findViewById(R.id.marqueetext); txtView.setSelected(true); <TextView android:id="@+id/marqueetext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="marquee" android:fadingEdge="horizontal" android:lines="1" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:text="hello all how are you hello all how are you hello all how are you hello all how are you" android:textColor="#ff4500" /> 

or another example ...

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:id="@+id/marqueetext" 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="hello all how are you hello all how are you hello all how are you hello all how are you hello all how are you" /> </RelativeLayout> 
+8
source
 android:singleLine="true" android:ellipsize="marquee" 

are the only attributes required, and scrolling even works with layout_weight defined with layout_width=0dp

here is a sample code:

 <TextView android:id="@+id/scroller" android:singleLine="true" android:ellipsize="marquee" android:textAppearance="?android:attr/textAppearanceLarge" android:textColor="#FFFFFF" android:text="Some veryyyyy long text with all the characters that cannot fit in screen, it so sad :( that I will not scroll" android:layout_marginLeft="4dp" android:layout_weight="3" android:layout_width="0dp" android:layout_height="wrap_content" /> 

but the most important is the TextView should be selected , which you have already executed in your code.

Hope this helps you.

+3
source

Try

 android:singleLine="true" 

instead

 android:lines="1" 

This will solve your problem.

+1
source

Source: https://habr.com/ru/post/1447404/


All Articles