`public class Sample extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new Draw (this));
}
private class Draw extends View {
public Draw (Context context) {
super(context);
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint paint1 = new Paint();
paint1.setColor(Color.BLUE);
paint1.setAntiAlias(true);
Paint paint2 = new Paint();
paint2.setColor(Color.BLACK);
paint2.setAntiAlias(true);
Paint paint3 = new Paint();
paint3.setColor(Color.YELLOW);
paint3.setAntiAlias(true);
Paint paint4 = new Paint();
paint4.setColor(Color.WHITE);
paint4.setAntiAlias(true);
Paint paint5 = new Paint();
paint5.setColor(Color.RED);
paint5.setAntiAlias(true);
canvas.drawColor(Color.BLACK);
canvas.drawCircle(200, 200, 180, paint1);
canvas.drawLine(220, 180, 280, 40, paint2);
canvas.drawLine(220, 180, 280, 40, paint2);
canvas.drawLine(260, 170, 370, 100, paint2);
canvas.drawLine(260, 170, 370, 100, paint2);
canvas.drawLine(380, 200, 260, 200, paint2);
canvas.drawLine(380, 200, 260, 200, paint2);
canvas.drawLine(350, 300, 260, 240, paint2);
canvas.drawLine(350, 300, 260, 240, paint2);
canvas.drawLine(280, 370, 230, 260, paint2);
canvas.drawLine(280, 370, 230, 260, paint2);
canvas.drawLine(200, 380, 200, 200, paint2);
canvas.drawLine(200, 380, 200, 200, paint2);
canvas.drawLine(100, 350, 200, 200, paint2);
canvas.drawLine(100, 350, 200, 200, paint2);
canvas.drawLine(40, 300, 200, 200, paint2);
canvas.drawLine(40, 300, 200, 200, paint2);
canvas.drawLine(120, 200, 20, 200, paint2);
canvas.drawLine(120, 200, 20, 200, paint2);
canvas.drawLine(40, 100, 200, 200, paint2);
canvas.drawLine(40, 100, 200, 200, paint2);
canvas.drawLine(120, 40, 200, 200, paint2);
canvas.drawLine(120, 40, 200, 200, paint2);
canvas.drawLine(200, 200, 200, 20, paint2);
canvas.drawLine(200, 200, 200, 20, paint2);
}
}
}`
我想显示圆圈,但是在 android sdk 上加载它时它太大了,我相信我需要一个位图代码,但不知道在哪里放置它......有人可以帮忙吗?