看效果效果:
接下来看代码(几乎每步都写着注释那,就直接放代码l):
package com.example.day06zhongbiao;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Build;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.util.AttributeSet;
import android.view.View;
import java.util.Calendar;
public class myview extends View {
private Paint hourPaint;//绘制时针的画笔
private Paint minPaint;//绘制分针的画笔
private Paint secPaint;//绘制秒针的画笔
public myview(Context context) {
super(context);
}
public myview(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Ov