Home > database >  Android Button Text not getting centered even with includeFontPadding=false
Android Button Text not getting centered even with includeFontPadding=false

Time:03-22

As mentioned button

<Button
                    android:layout_width="168dp"
                    android:layout_height="40dp"
                    android:layout_marginStart="140dp"
                    android:layout_marginTop="80dp"
                    android:gravity="center"
                    android:background="@drawable/button_borders"
                    android:fontFamily="@font/fontpragatinarrow_bold"
                    android:includeFontPadding="false"
                    android:text="@string/check"
                    android:textSize="21sp" />

Edit : If layout_height is switched to wrap_content:

wrap_content

CodePudding user response:

Just use "wrap_content" for width and height

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="button"/>

enter image description here

CodePudding user response:

<Button
                android:layout_width="168dp"
                android:layout_height="40dp"
                android:layout_marginStart="140dp"
                android:layout_marginTop="80dp"
                android:gravity="center_horizontal|center_vertical"
                android:background="@drawable/button_borders"
                android:fontFamily="@font/fontpragatinarrow_bold"
                android:includeFontPadding="false"
                android:text="@string/check"
                android:textSize="18sp" />

android:gravity="center_horizontal|center_vertical"

  • Related