在使用CardView的时候发现,当CardView包含一个布局之后设置 圆角,cardview显示出来之后 四周 会有一个类似padding的属性。
但是在布局文件里面,内层控件和CardView是没有设置padding 的。
要去掉 这个自动添加的 padding 可以通过 属性
cardview:cardPreventCornerOverlap
来设置为 false。
在代码里面 也就是 setPreventCornerOverlap (false)
官方文档描述
On API 20 and before, CardView does not clip the bounds of the Card for the rounded corners. Instead, it adds padding to content so that it won't overlap with the rounded corners.
在api20(lollipop)之前,cardview在圆角情况下,不会去掉边缘部分。 所以 ,通过添加类似padding的属性,使得在圆角情况下不会,交叠在一起。