How to fix textview overflow text with android add-on: ellipsize = "marquee"

On some Android devices (LG Google Nexus 5 with Android L and M) TextView with android: ellipsize = "marquee" and complements the results in text overflowing the text image. This happens on the right side, but not on the left side of the TextView, although the addition applies to both the left and right sides.

screenshot

This does not happen on Samsung Galaxy S3 and S6 with Android K and L respectively.

<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="1dp" android:paddingTop="2dp" android:paddingBottom="2dp" android:paddingLeft="4dp" android:paddingRight="4dp" android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:freezesText="true" android:alpha="0.85" android:background="@color/by433_gray_darker" android:textColor="@color/white" android:textSize="11sp" /> 

What can I do to fix or get around this?

+7
android textview ellipsis nexus-5
source share
1 answer

Your problem is related to the Android error and has already been reported and assigned to the Android Open Source Project:

Your workaround might look like this:

 <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="2dp" android:paddingBottom="2dp" android:paddingLeft="4dp" android:paddingRight="4dp" android:layout_marginBottom="1dp" android:background="@color/by433_gray_darker"> <TextView android:id="@+id/textId" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally="true" android:freezesText="false" android:alpha="0.85" android:text="super nice text text text text text text text text text text text text text text text text text" android:textColor="@color/white" android:textSize="11sp" /> </FrameLayout> 

So, the idea is to have a wrapper container with paddings, fields and a background. (This should not be a big load if you only have a couple of such views)


The original incorrect answer (although there were two TextViews) The problem may be due to the combination of so many attributes in your TextView. Here are some suggestions:

  • First try removing the attribute one at a time, checking the result
  • You can try specifying gaskets on the container instead of text views
  • From your layout, it seems that you can try something like this instead of match_parent in your text views:

     <LinearLayout android:orientation="horizontal" ...> <TextView android:layout_width="0dp" android:layout_weight="1" ... /> <TextView android:layout_width="0dp" android:layout_weight="1" ... /> </LinearLayout> 
+2
source share

All Articles