CardView继承FrameLayout,可以设置圆角和阴影
app:cardCornerRadius="10dp"
cardView.setRadius(radius)
app:cardElevation="10dp"
cardView.setElevation(elevation)
app:contentPadding="10dp"
app:cardUseCompatPadding="true"
app:cardBackgroundColor="@color/selector_item_bg"
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="5dp"
app:cardBackgroundColor="@color/selector_item_bg"
app:cardCornerRadius="5dp"
app:cardUseCompatPadding="true">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
android:src="@drawable/icon_tab_publish"
app:elevation="8dp" />
用法和button没什么区别
fab.setOnClickListener {
}
用于提示用户,用户可操作的控件,用法和toast类似
Snackbar.make(it,"data deleted",Snackbar.LENGTH_LONG)
.setAction("cancel",object :View.OnClickListener{
override fun onClick(p0: View?) {
}
}).setBackgroundTint(Color.GRAY)
.setActionTextColor(Color.BLACK)
.setTextColor(Color.WHITE)
.show()