RandomColor randomColor = new RandomColor();
int color = randomColor.randomColor(); //随机生成一个颜色值
Drawable myIcon = getContext().getResources().getDrawable(R.drawable. overshape); //获得一个圆形图形作为背景
ColorFilter filter = new LightingColorFilter( color, color); //给图形动态设置颜色
myIcon.setColorFilter(filter);
holder. avatar.setBackground(myIcon);
overshape.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape= "oval" >
<solid android:color= "#33ccff"/>
<size android:width= "46dip"
android:height= "46dip"/>
</shape>
----
spring mvc+tomcat源码分析视频(链接复制在浏览器打开)
https://study.163.com/course/courseMain.htm?share=2&shareId=480000001919582&courseId=1209399899&_trace_c_p_k2_=6d81bc445e9c462ab8d6345e40f6b0bf