标签:
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; } */ }
标签:
原文地址:http://www.cnblogs.com/jsonfan/p/5370595.html