[MaterialButton] drawableStart doesn't work, both in preview nor in device
See original GitHub issueDescription: [MaterialButton] android:drawableStart doesn’t work, both in preview nor in device. It ended up the same whether you’re using xml drawable or bitmap.
Expected behavior: Drawable expected to be drawn at the start of the MaterialButton.
Resulted behavior: From top to bottom: drawableEnd - drawableStart - drawableTop - drawableBottom
Source code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
tools:context=".MainActivity">
<com.google.android.material.button.MaterialButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:drawableEnd="@drawable/ic_android_black_24dp"/>
<com.google.android.material.button.MaterialButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:drawableStart="@drawable/ic_android_black_24dp"/>
<com.google.android.material.button.MaterialButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:drawableTop="@drawable/ic_android_black_24dp"/>
<com.google.android.material.button.MaterialButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:drawableBottom="@drawable/ic_android_black_24dp"/>
</LinearLayout>
Android API version: API 22 and above; might have also happened on earlier APIs.
Material Library version: 1.1.0
Device: Android Studio Emulator
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:15 (4 by maintainers)
Top Results From Across the Web
drawable start not working with material button - Stack Overflow
I am using material themes, so this will be inflated into a material button drawableStart has no effect at all, however drawableEnd, bottom...
Read more >MaterialButton - Android Developers
A convenience class for creating a new Material button. This class supplies updated Material styles for the button in the constructor.
Read more >Want To Add Icon On Button, Drawabletop Is Not Working ...
Description: [MaterialButton] android:drawableStart doesn't work both in preview nor in device. It ended up the same whether you're using xml drawable or ...
Read more >TextView drawableTint not working with drawableStart ...
I'm currently developing Android application and I found this issue. Development Env - compileSdkVersion 23 - buildToolsVersion 23.0.1. How to reproduce
Read more >Different Ways to Fix "Android Studio Does not Show Layout ...
Just try a method if that doesn't work skip to the next method. ... and still not able to see the Layout Preview,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey there!
Instead of using
drawableBottom|Top|Left|...
useMaterialButton
’s attributesapp:icon
andapp:iconGravity
.Like:
The above is from our catalog demo app here: https://github.com/material-components/material-components-android/blob/master/catalog/java/io/material/catalog/button/res/layout/cat_buttons_fragment.xml#L140-L141
I’m going to go ahead and close this but if this isn’t what you were asking or doesn’t solve the issue, feel free to reopen!
I think Material Button should support drawableStart, End, etc. though.
Because there’s a case where we need multiple icons on a button: