<?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"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.button.MaterialButton
android:layout_width="150dp"
android:layout_height="60dp"
android:text="圆角"
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:textColor="#ff0000"
android:textSize="18dp"
app:strokeColor="@color/purple_500"
app:strokeWidth="2dp"
app:cornerRadius="30dp"/>
<com.google.android.material.button.MaterialButton
android:layout_width="wrap_content"
android:layout_height="60dp"
android:text="圆角"
android:layout_margin="10dp"
android:textColor="#ff0000"
android:textSize="18dp"
app:iconPadding="20dp"
app:icon="@android:drawable/star_on"
app:strokeColor="#fff000"
app:strokeWidth="2dp"
android:insetTop="0dp"
android:insetBottom="0dp"
app:iconTint="@color/purple_200"
app:iconGravity="start"
app:cornerRadius="30dp"/>
</LinearLayout>
4个点使用注意事项:
修改主题防闪退: android:theme="@style/Theme.MaterialComponents.Light.NoActionBar"
去掉阴影:
android:theme="@style/Theme.MaterialComponents.Light.NoActionBar"
设置app命名空间:
xmlns:app="http://schemas.android.com/apk/res-auto"
build-gradle添加依赖:
implementation 'com.google.android.material:material:1.5.0'
其它属性多用用就记住了