Search code examples
androidtextviewoverlap

Font size in settings makes text in a TextView unreadable and overlapped


Everything in the app looks fine until the font size is increased in the settings page on Android phones.

Image of Text Before Font Size Change

But as soon as the font size is increased in settings, the text overlaps each line.

Image of Text After Font Size Change

Here's the code for the TextView

<TextView
            android:id="@+id/song_lyrics"
            android:textSize="14sp"
            android:minHeight="32dp"
            android:textColor="@color/black"
            android:lineSpacingMultiplier="1.2"
            android:letterSpacing=".06"
            android:textStyle="normal"
            android:layout_marginTop="24dp"
            android:layout_marginRight="24dp"
            android:layout_marginLeft="24dp"
            android:layout_marginBottom="24dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:lineHeight="16dp"
            android:text="Abraham’s blessings are mine (bis) \nI am blessed in the morning, \nI am blessed in the evening,\nAbraham’s blessings are mine."/>

Solution

  • The error was in my code, I tried to use both the android:lineHeight attribute and the android:lineSpacingMultiplier attribute.

    Don't use lineHeight for this type of problem, use lineSpacingMultipler or lineSpacingExtra.

    Lesson learned :)