Why the button text it’s not wrap_content and gone when I custom Hight and custom background?

Why the button text it’s not wrap_content and gone when I custom Hight and custom background?

XML Code:

<Button
            android:id="@+id/button_create"
            android:layout_width="wrap_content"
            android:layout_height="35dp"
            android:layout_marginEnd="8dp"
            android:background="@drawable/bg_button_3"
            android:text="@string/create"
            android:theme="@style/FontTheme1"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

enter image description here

Answer

Your issue is the height. Use:

android:layout_height="wrap_content"

In any case you don’t need a custom background to have rounded corners.
Just use:

<com.google.android.material.button.MaterialButton
   ....
   style="@style/Widget.MaterialComponents.Button"
   app:cornerRadius=".."
    .../>

Leave a Reply

Your email address will not be published. Required fields are marked *