java.lang.ClassCastException: android.graphics.drawable.ColorDrawable cannot be cast to android.support.v7.widget.RoundRectDrawableWithShadow 我在给CardView组件设置背景颜色属性时,起初是按照如下方法做的:
cardView.setBackgroundColor(Color.parseColor("#ffffff")); 但是运行后却报错,提示类型转换错误:java.lang.ClassCastException: android.graphics.drawable.ColorDrawable cannot be cast to android.support.v7.widget.RoundRectDrawableWithShadow
解决方案cardView.setCardBackgroundColor(Color.parseColor("#ffffff")); 来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2873/viewspace-2799788/ ,如需转载,请注明出处,否则将追究法律责任。