Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center align text in Extended Floating Action Button?

I want to center align the text in the extended floating action button but I'm not able to do that. As you can see in the image below the text is not centrally aligned.

enter image description here

Here's is the code for extended floating action button:

<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
        android:id="@+id/compress_start_fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        android:text="S"
        app:backgroundTint="?android:colorAccent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        android:textColor="@color/textColorPrimaryDark"
        app:layout_constraintStart_toStartOf="parent"
        android:textAlignment="center"
        />

Am I doing anything wrong? Any help will be appreciated.

like image 644
Jazib Khan Avatar asked Feb 26 '21 15:02

Jazib Khan


1 Answers

Please add these two lines in your ExtendedFloatingActionButton

 android:paddingStart="0dp"
 android:paddingEnd="0dp
like image 64
Shay Kin Avatar answered Nov 08 '22 22:11

Shay Kin