继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

ClassCastException:ColorDrawable

猴子搬来的救兵Castiel
关注TA
已关注
手记 77
粉丝 40
获赞 184
原标题:ClassCastException:ColorDrawable cannot be cast to RoundRectDrawableWithShadow 错误信息
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"));
打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP