question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[MaterialButton] Add support for TOP & BOTTOM icon gravity

See original GitHub issue

Is your feature request related to a problem? Please describe. Up until release 1.1.0-alpha06 back in May 2019, the only way to change the icon position was done using TextViewCompat.setCompoundDrawablesRelative.

After introducing new method setIconGravity in release 1.1.0-alpha06 it was finally possible to properly set the icon position, although only on the right or left, and close to the text or not.

This now excludes the possibility to place the icon either on top or bottom relative to the text.

Describe the solution you’d like Please kindly add TOP & BOTTOM gravity as part of @IconGravity.

Describe alternatives you’ve considered As said at the beginning, before release 1.1.0-alpha06, the only way to change the icon position was using TextViewCompat.setCompoundDrawablesRelative.

This no longer works, as it triggers a requestLayout which, at some point, will trigger updateIconPosition and then updateIcon where only START/TEXT & END/TEXT are supported.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:9
  • Comments:20 (13 by maintainers)

github_iconTop GitHub Comments

8reactions
hrachcommented, Oct 11, 2019

Actually, in Gmail, there are buttons which have the icon on the left, but when insufficient width is there, they push the icon on the top. Seems pretty useful.

image image

7reactions
rewgoescommented, Mar 22, 2020

I’ve sent a PR adding top gravity only, let’s wait if it is approved!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to position icon position in materialbutton - Stack Overflow
You can use the app:iconGravity attribute. Use the app:iconGravity="end" value. enter image description here.
Read more >
MaterialButton - Android Developers
Add icons to the start, center, or end of this button using the app:icon ... Gravity used to position the icon at the...
Read more >
Hands-on with Material Components for Android: Buttons
This post will be covering the features and API of Button components. To find out how to handle initial setup of Material Components...
Read more >
Common buttons – Material Design 3
Buttons. Buttons help people initiate actions, from sending an email, to sharing a document, to liking a post.
Read more >
Android Material Button With Icon On Top Of Text - ADocLib
Add icons to the start center or end of this button using the app:icon Content ... Ask questions[MaterialButton] Add support for TOP &...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found