package com.naozary.android.example.simple;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.os.Bundle;
import android.view.View;
public class simple extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.main);
setContentView(new GraphicsTestView(this));
}
}
class GraphicsTestView extends View {
public GraphicsTestView(Context context) {
super(context);
}
@Override
protected void onDraw(Canvas canvas) {
Paint paint = new Paint();
paint.setColor(
Color.argb(
255, // 透明度
255, // Red
255, // Green
0 // Blue
)
);
paint.setAntiAlias(true);
RectF ovalF = new RectF(
120.5f, // The X coordinate of the left side of the rectagle
80.5f, // The Y coordinate of the top of the rectangle
160.5f, // The X coordinate of the right side of the rectagle
120.5f // The Y coordinate of the bottom of the rectangle
);
canvas.drawOval(ovalF, paint); // 楕円描画
ovalF = new RectF(
120.5f,
150.5f,
160.5f,
220.5f
);
canvas.drawOval(ovalF, paint); // 楕円描画
}
}
【実行結果】
0 件のコメント:
コメントを投稿