Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a drawable to right side of text in MaterialButton?

I am doing in this way

<com.google.android.material.button.MaterialButton
        android:id="@+id/btnProceed"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Proceed to enter Gender"
        style="@style/bottomBtnStyle"
        app:icon="@drawable/ic_right_arrow"
        app:iconGravity="textStart"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"/>

But icon is getting displayed on left side of text, icon gravity has no effect on icon position. In normal Buttons we used to achieve same with drawableRight, but here not finding a way.

like image 453
Anupriya Avatar asked Oct 28 '25 16:10

Anupriya


1 Answers

app:icon="@drawable/ic_right_arrow" 

is fine if you need to show in left. And for to show right you need to add app:iconGravity="end" too.

And make sure you are using correct style for button. It means parent of bottomBtnStyle must be Widget.MaterialComponents.Button

like image 91
Pankaj Kumar Avatar answered Oct 31 '25 12:10

Pankaj Kumar