如何在Android中获取实质性的图标按钮? [英] How to get material icon button in Android?

查看:85
本文介绍了如何在Android中获取实质性的图标按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在android中获取一个材质按钮?我已经尝试过此代码,但不知道如何包含这样的图像:

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"/>

推荐答案

对于Material Button,请使用iconiconGravity属性,如下所示:

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"/>

仔细阅读文档以更好地理解:此处

Go through docs for better understanding:Here

这篇关于如何在Android中获取实质性的图标按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆