简介
- Android 5.0 版本中新增。
- 继承自 FrameLayout 类。
- 可以设置圆角和阴影,使得控件具有立体性。
- 可以包含其他的布局容器和控件。
导包
implementation 'androidx.cardview:cardview:1.0.0'
属性
xml 属性
-
app:cardBackgroundColor:设置背景色
-
app:cardCornerRadius:设置圆角
-
app:cardElevation:设置 Z 轴阴影
-
app:cardMaxElevation:Z 轴最大高度值
-
app:cardPreventCornerOverlap:是否使用 PreventCornerOverlap
-
app:cardUseCompatPadding:配合 app:cardElevation=“30dp”
当 app:cardUseCompatPadding=“false” 时,阴影在外面
当 app:cardUseCompatPadding=“true” 时,阴影在里面
-
app:contentPadding:内容的 padding
-
app:contentPaddingBottom:内容的底 padding
-
app:contentPaddingLeft:内容的左 padding
-
app:contentPaddingRight:内容的右 padding
-
app:contentPaddingTop:内容的上 padding
代码属性
//对应 app:cardBackgroundColor public void setCardBackgroundColor(@ColorInt int color) public void setCardBackgroundColor(@Nullable ColorStateList color) //对应 app:cardCornerRadius public void setRadius(float radius) //对应 app:cardElevation public void setElevation(float elevation) //对应 app:cardMaxElevation public void setMaxCardElevation(float maxElevation) //对应 app:contentPadding public void setContentPadding(@Px int left, @Px int top, @Px int right, @Px int bottom)
本文地址:https://blog.csdn.net/csdn1225987336/article/details/109027075
您可能感兴趣的文章:
如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!
网友评论