I am using supportLibrary = "28.0.0-beta01" version.
Here is my code in .xml file:
<android.support.design.button.MaterialButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:icon="@drawable/ic_my_orders"
app:iconGravity="textStart"
android:gravity="center"/>
To my code icon of the drawable locating left side of the button. I want to set button to the center. I want to achieve this result
Edit
I don't need to any custom views or hard coded things. If this is a bug (app:iconGravity), I will wait next release.
EDIT
The bug fixed in the version 28.0.0-rc01,just change the version.
You can use width to wrap_content so it matches your text. And layout_gravity instead of gravity to set the button its own gravity (and not its childs).
The code snippet you have in your original question is correct. This has been identified as a bug and will be fixed in the upcoming release.
UPDATED
Try this code to set left padding of button to make it center.
JAVA
OUTPUT