1

When using maxLines="1" in combination with gravity="center" and ellipsize="end", the text gets clipped from the beginning.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        style="@style/TextAppearance.MaterialComponents.Body1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"
        android:gravity="center"
        android:ellipsize="end"
        android:maxLines="1"
        android:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s" />

</LinearLayout>

enter image description here

The issue gets resolved if maxLines="1" is changed to singleLine="true", but it's a deprecated attribute.

Reza Bigdeli
  • 1,142
  • 1
  • 12
  • 25

1 Answers1

4

It seems that TextAppearance.MaterialComponents.Body… sets android:letterSpacing to something more than zero. When this attribute is set to android:letterSpacing="0.0" the issue gets resolved.

Reza Bigdeli
  • 1,142
  • 1
  • 12
  • 25
  • hello reza :), can you help me with this please? https://stackoverflow.com/questions/62887229/cant-zoom-the-webview-under-swipe-to-refresh/62887494 – madan Jul 15 '20 at 09:01