how to set materialButton icon to the center

Muhammadakbar Rafiqov picture Muhammadakbar Rafiqov · Aug 1, 2018 · Viewed 11.3k times · Source

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 enter image description here


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.

Answer

Gautham Sajith picture Gautham Sajith · Aug 4, 2018

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.