Marquee text does not work in widgets

Here is the situation, I have a widget containing two text views, and I want the text to scroll if its width exceeds the width of the layout. The problem is that the selection area works to represent the bottom text, but does not work for the top. I am attaching a piece of code. Can you tell me what I'm 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> 
+4
source share
2 answers

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> 
+3
source

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

 textview.setMovementMethod(new ScrollingMovementMethod()); 
0
source

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


All Articles