我在Android中为CardView设置了随机颜色。
如何在运行时以编程方式获取CardView的背景颜色?
Random rnd = new Random();
int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
holder.cardView.setBackgroundColor(color);
如何在运行时以编程方式获取CardView的背景颜色?
Color.rgb(...)
替换Color.argb(255,...)
,如果alpha值始终为255,则无需使用Color.argb(...)
。 - Omar Hemaia