1.先准备好图片
2.新建一个CreditScoreView类,继承View
public class CreditScoreView extends View { //数据个数 private int dataCount = 5; //每个角的弧度 private float radian = (float) (Math.PI * 2 / dataCount); //雷达图半径 private float radius; //中心X坐标 private int centerX; //中心Y坐标 private int centerY; //各维度标题 private String[] titles = {"履约能力", "信用历史", "人脉关系", "行为偏好", "身份特质"}; //各维度图标 private int[] icons = {R.mipmap.ic_performance, R.mipmap.ic_history, R.mipmap.ic_contacts, R.mipmap.ic_predilection, R.mipmap.ic_identity}; //各维度分值 private float[] data = {170, 180, 160, 170, 180}; //数据最大值 private float maxValue = 190; //雷达图与标题的间距 private int radarMargin = DensityUtils.dp2px(getContext(), 15); //雷达区画笔 private Paint mainPaint; //数据区画笔 private Paint valuePaint; //分数画笔 private Paint scorePaint; //标题画笔 private Paint titlePaint; //图标画笔 private Paint iconPaint; //分数大小 private int scoreSize = DensityUtils.dp2px(getContext(), 28); //标题文字大小 private int titleSize = DensityUtils.dp2px(getContext(), 13); public CreditScoreView(Context context) { this(context, null); } public CreditScoreView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public CreditScoreView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } private void init() { mainPaint = new Paint(); mainPaint.setAntiAlias(true); mainPaint.setStrokeWidth(0.3f); mainPaint.setColor(Color.WHITE); mainPaint.setStyle(Paint.Style.STROKE); valuePaint = new Paint(); valuePaint.setAntiAlias(true); valuePaint.setColor(Color.WHITE); valuePaint.setAlpha(120); valuePaint.setStyle(Paint.Style.FILL_AND_STROKE); scorePaint = new Paint(); scorePaint.setAntiAlias(true); scorePaint.setTextSize(scoreSize