2

I was trying google fonts to use in my android mobile application. I've noticed that when I used custom font, the center alignment to element (EditText, Button) has bigger space at the bottom. Tried lineSpacingMultiplier and lineSpacingExtra but it doesn't work. If I turned back to default Roboto font it works just fine.

enter image description here

<EditText
        android:id="@+id/input_phone"
        android:layout_width="300sp"
        android:layout_height="60sp"
        android:layout_marginTop="296dp"
        android:autofillHints="@string/label_phone"
        android:background="@drawable/custom_input"
        android:hint="@string/label_phone"
        android:inputType="phone"
        android:maxLength="11"
        android:textAlignment="center"
        android:textSize="30sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:ignore="LabelFor" />

// custom_input
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <stroke
        android:color="@color/colorSecondary"
        android:width="2sp" />
    <corners android:radius="10sp" />
    <padding
        android:bottom="10sp"
        android:left="10sp"
        android:right="10sp"
        android:top="10sp" />
</shape>

I suspect that it has something to do with the font but I need to make the font input bigger so I specified it.

Rye
  • 445
  • 4
  • 15

1 Answers1

1

Upon further research, this solved my issue,

android:includeFontPadding="false"

Ref: Android: TextView: Remove spacing and padding on top and bottom

Rye
  • 445
  • 4
  • 15