0

I've been having an issue with the vertical alignment of the text inside a button, but only on Samsung devices. The problem is that when I go to the settings and set the maximum font size (from normal to huge, so the size changes across all the apps) the text is no more aligned properly, it's more like it's anchored to the bottom of the button. Here's the layout:

<Button
    android:id="@+id/btn"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:background="@drawable/phase_button_background"
    android:ellipsize="end"
    android:gravity="center"
    android:paddingEnd="@dimen/phase_button_padding"
    android:paddingLeft="@dimen/phase_button_padding"
    android:paddingRight="@dimen/phase_button_padding"
    android:paddingStart="@dimen/phase_button_padding"
    android:singleLine="true"
    android:textAllCaps="false"
    android:textColor="@color/phase_button_text_color"
    android:textSize="@dimen/phase_button_text_size"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintLeft_toRightOf="@+id/message"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintStart_toEndOf="@+id/message"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintWidth_default="wrap"
    tools:text="Some text here"
    tools:textColor="#d7000000"
    tools:textSize="18sp"
    tools:visibility="visible"/>
Hardik Vasani
  • 828
  • 1
  • 8
  • 13
Matvey Rybakov
  • 660
  • 1
  • 12
  • 19

1 Answers1

0

Alright, it turned out that on some devices including Samsung ones font padding plays a huge role and is especially noticable when using big fonts. So in order to fix the problem all I had to do was adding this line to my layout:

android:includeFontPadding="false"
Matvey Rybakov
  • 660
  • 1
  • 12
  • 19