Android CardView setRadius()无效问题
作者:互联网
CardView代码中设置圆角会被设置背景覆盖,以下代码运行后cardview圆角无效:
card.setBackgroundResource(R.id.image);
card.setRadius(50);
应改成:
//card.setBackgroundResource(R.id.image);
card.setRadius(50);
ImageView img = new ImageView(getContext());
LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT
);
img.setLayoutParams(params1);
img.setBackgroundResource(R.id.image);
card.addView(img);
标签:img,LayoutParams,image,CardView,id,Android,setRadius,LinearLayout,card 来源: https://blog.csdn.net/loahpotato/article/details/120903443