1 在实际的开发中,对应阴影的效果或者单个卡片,我们喜欢使用cardView 这个控件
但是这个控件在使用的过程中要注意对于 5.0 + 版本的兼容
可以单独做处理
@SuppressLint("ViewConstructor")
public class CustomCardView extends CardView {
public CustomCardView(Context context, int radiusDP) {
super(context);
MarginLayoutParams lp = new MarginLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
lp.leftMargin = lp.rightMargin = DPIUtil.dip2px(20);
// lp.topMargin = lp.bottomMargin = DPIUtil.dip2px(12);
setLayoutParams(lp);
setRadius(DPIUtil.dip2px(radiusDP));
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
setElevation(0.0f);
}
}
}