package com.exaple.day01rikao;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

public class Myview extends View {

	public Myview(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		// TODO Auto-generated constructor stub
	}

	public Myview(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}

	public Myview(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}

	@Override
	protected void onDraw(Canvas canvas) {
		Paint pa = new Paint();
		Paint pa1 = new Paint();
		float wi = canvas.getWidth();
		float he = canvas.getHeight();
		pa.setColor(Color.BLACK);
		pa1.setColor(Color.WHITE);

		canvas.drawColor(Color.WHITE);
		canvas.drawCircle(wi / 2, he / 2, 60, pa);
		canvas.drawCircle(wi / 2, he / 2, 55, pa1);
		canvas.drawText("hhhhhhhhhhhhhh", wi/4, he/4, pa);
		super.onDraw(canvas);
	}

	/*
	 * @Override public boolean onTouchEvent(MotionEvent event) { wi =
	 * event.getX(); he = event.getY(); this.invalidate();
	 * 
	 * return true; }
	 */

}

 自定义view 画圆 

相关文章:

  • 2021-07-20
  • 2021-10-05
  • 2021-09-30
  • 2021-08-31
  • 2021-09-06
  • 2021-08-05
  • 2021-06-09
  • 2022-12-23
猜你喜欢
  • 2021-12-23
  • 2021-12-07
  • 2021-05-29
  • 2022-12-23
  • 2021-11-07
  • 2021-06-13
  • 2021-10-31
相关资源
相似解决方案