8

So, this question is a duplicate, but the answers I have read doesn't work for me. If fact, they don't seem to have worked for other people either, so I'll give it another shot and see if someone knows the answer.

When Adding a textView, it looks like this

As you can see there is definitely a lot of space between the blue layout-marking and the actual text. When placing one textView on top of another the space becomes quite noticeable. Note that this is after I have added the XML code lines:

android:includeFontPadding="false"

(Which works to a small extent) and:

android:lineSpacingExtra="0dp"

(Which is said to solve the problem according to other threads, but does nothing for me for some reason).

The full XML for my textView is:

<TextView
    android:id="@+id/healthTextId"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:fontFamily="sans-serif"
    android:includeFontPadding="false"
    android:lineSpacingExtra="0dp"
    android:text="Test"

    android:textAlignment="center"
    android:textColor="@color/colorHealth"

    android:textSize="100dp"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

The problem persists on both default and custom fonts. Any ideas?

This is one of the threads I read that unfortunately didn't solve the issue for me: Android: TextView: Remove spacing and padding on top and bottom

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
johanjohansson
  • 491
  • 1
  • 9
  • 17

2 Answers2

0

This problem is very annoyying. Even if you remove all paddings, the padding of the font itself remains. Try this answer. This is a good approach.

Faisal Khan
  • 548
  • 3
  • 16
-3

Just android:padding="0dp" should work.

Yunnosch
  • 26,130
  • 9
  • 42
  • 54
Harsh Modani
  • 205
  • 1
  • 11