- 效果图

- 引入
implementation 'com.google.android.material:material:1.4.0'
- 属性
属性 | 描述 |
---|
android:id | 控件Id |
android:layout_width | 控件长度 |
android:layout_height | 控件高度 |
app:cardBackgroundColor | 背景色 |
app:cardCornerRadius | 4个角得圆角半径 |
app:cardElevation | 阴影大小 |
app:strokeColor | 边框线颜色 |
app:strokeWidth | 边框线宽度 |
- 源代码
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.card.MaterialCardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
app:cardBackgroundColor="@color/teal_200"
app:cardCornerRadius="8dp"
app:cardElevation="9dp"
app:strokeColor="@color/black"
app:strokeWidth="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="56dp"
android:layout_gravity="center"
android:gravity="center"
android:text="AAA"
android:textColor="@color/white" />
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bottomAppBar"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_gravity="bottom"
app:backgroundTint="@color/black"
app:hideOnScroll="true"
app:menu="@menu/bab_menu" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/icon_scan"
app:fabSize="normal"
app:layout_anchor="@id/bottomAppBar" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>