Reputation: 4494
How can I get a material button in android? I have tried this code but don't know how to include an image like this:
<com.google.android.material.button.MaterialButton
android:id="@+id/material_button"
style="@style/Widget.MaterialComponents.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add to Cart"/>
Upvotes: 22
Views: 20732
Reputation: 4494
For Material Button
use icon
and iconGravity
properties like below:
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.Icon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Icon Button"
app:icon="@drawable/your_icon"
app:iconGravity="textStart"/>
Docs : Here
Upvotes: 41