如何在Android中获取material图标按钮?

How to get material icon button in Android?

如何在 android 中获得 material 按钮?我试过这段代码,但不知道如何包含这样的图像:

<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 属性,如下所示:

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

阅读文档以更好地理解:Here