1、添加依赖: implementation 'com.google.android.material:material:1.3.0' 2、改app主题,使用的主题需继承material中的主题: <style name="Theme.PlusDemo" parent="Theme.MaterialComponents.Light.NoActionBar"> 3、布局中使用 <com.google.android.material.button.MaterialButton android:id="@+id/button2" style="@style/Widget.MaterialComponents.Button.UnelevatedButton"<!-- 去阴影 --> android:layout_width="wrap_content" android:layout_height="80dp" android:backgroundTint="#987654"<!-- 背景色 --> android:gravity="center" android:insetTop="0dp"<!-- 去顶部留白 --> android:insetBottom="0dp"<!-- 去底部留白 --> android:padding="20dp" android:text="@string/button" android:textSize="20sp" app:cornerRadius="40dp"<!-- 圆角 --> app:icon="@drawable/clean"<!-- 图标 --> app:iconGravity="textEnd"<!-- 图标位置 --> app:iconPadding="@dimen/dp_10"<!-- 图标文字距离 --> app:iconSize="40dp"<!-- 图标大小 --> app:iconTint="#ff0"<!-- 图标着色 --> app:iconTintMode="multiply"<!-- 图标着色模式 --> app:rippleColor="#B300FF"<!-- --> app:strokeColor="#f00"<!-- 描边颜色 --> app:strokeWidth="2dp"<!-- 描边宽度 --> /> <com.google.android.material.button.MaterialButtonToggleGroup android:layout_width="match_parent" android:layout_height="20sp" android:orientation="horizontal" app:checkedButton="@+id/button2"<!-- 默认选中项 --> app:singleSelection="true"<!-- 是否单选 --> app:selectionRequired="true"<!-- true:强制至少选中一个 --> /> 可以自己写选中,点击状态,也可以尝试一下不同模式的区别