Skip to content

Commit

Permalink
扩展可重写接口
Browse files Browse the repository at this point in the history
  • Loading branch information
lvmo committed Mar 20, 2019
1 parent 9491f25 commit 1042f12
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions radarview/src/main/java/com/frasker/radarview/RadarView.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class RadarView extends View {

private float radarLineWidth = 0.5f;//雷达网线宽度dp
private float valueLineWidth = 1f;//数据区边宽度dp
private float valuePointRadius = 3f;//数据区圆点半径dp
private float valuePointRadius = 2f;//数据区圆点半径dp
private float textSize;//字体大小sp

private int mWidth, mHeight;
Expand All @@ -66,7 +66,7 @@ public RadarView(Context context, AttributeSet attrs) {

public RadarView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
//setLayerType(View.LAYER_TYPE_SOFTWARE, null); 应该没有用到限制API
mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RadarView);
defaultRadius = typedArray.getDimension(R.styleable.RadarView_r_radius, -1);
Expand Down Expand Up @@ -156,14 +156,23 @@ private void reset() {
@Override
protected void onDraw(Canvas canvas) {
canvas.translate(mWidth / 2, mHeight / 2);

if (isDataListValid()) {
drawBefore(canvas);
drawSpiderweb(canvas);
drawText(canvas, mArrayDotX[axisTickCount], mArrayDotY[axisTickCount], count);
drawRegion(canvas);
drawAfter(canvas);
}
}

protected void drawAfter(Canvas canvas) {

}

protected void drawBefore(Canvas canvas) {

}


Path webPath = new Path();
Path linePath = new Path();
Expand Down Expand Up @@ -325,7 +334,7 @@ protected void drawDataCircle(Canvas canvas, float x, float y) {
circlePaint.setColor(valueLineColor);
circlePaint.setStrokeWidth(dip2px(getContext(), valueLineWidth));
circlePaint.setStyle(Paint.Style.STROKE);
canvas.drawCircle(x, y, valuePointRadius, circlePaint);
canvas.drawCircle(x, y, dip2px(getContext(), valuePointRadius), circlePaint);
}
}

Expand Down

0 comments on commit 1042f12

Please sign in to comment.