Material-components-android: Support end iconGravity for MaterialButton

Created on 22 Dec 2018  路  3Comments  路  Source: material-components/material-components-android

Most helpful comment

Hi this was addressed here:

http://issuetracker.google.com/111948796

If you really need this you could use iconGravity start and invert the layout direction.

All 3 comments

Hi this was addressed here:

http://issuetracker.google.com/111948796

If you really need this you could use iconGravity start and invert the layout direction.

@ymarian doesn't that look like a workaround?
I have already posted this in comments here: [Material Button] Add iconGravity="end", but didn't get any response, so:

I have a regular android button with an icon at the end and a custom background shape drawable. But because I'm using Theme.MaterialComponents.Light.NoActionBar my button gets changed to MaterialButton that doesn't support icon at the end and doesn't have specified background drawable.
So in this case I have either use Theme.MaterialComponents.Light.NoActionBar.Bridge or use TextView instead of button. Neither option seems like a good solution to me. Any ideas how to make this right?

@mnayef95 you can use:

        Drawable d = TextViewCompat.getCompoundDrawablesRelative(startButton)[0]; // the start drawable
        TextViewCompat.setCompoundDrawablesRelative(startButton, null, null, d, null); // move it to the end

Was this page helpful?
0 / 5 - 0 ratings