import android.app.*;
import android.content.*;
import android.graphics.*;
import android.graphics.Paint.Style;
import android.os.*;
import android.view.*;
public class ShapeTest extends Activity
{
class RenderView extends View
{
Paint paint;
public RenderView(Context context)
{
super(context);
paint = new Paint();
}
protected void onDraw(Canvas canvas)
{
canvas.drawRGB(255, 255, 255);
paint.setColor(Color.RED);
canvas.drawLine(
0,
0,
canvas.getWidth()-1,
canvas.getHeight()-1,
paint);
paint.setStyle(Style.STROKE);
paint.setColor(0xff00ff00);
canvas.drawCircle(
canvas.getWidth()/2, //cx
canvas.getHeight()/2, //cy
40, //radius
paint);
paint.setStyle(Style.FILL);
paint.setColor(0x770000ff);
canvas.drawRect(100, 100, 200, 200, paint);
invalidate();
}
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
);
setContentView(new RenderView(this));
}
}
import android.content.*;
import android.graphics.*;
import android.graphics.Paint.Style;
import android.os.*;
import android.view.*;
public class ShapeTest extends Activity
{
class RenderView extends View
{
Paint paint;
public RenderView(Context context)
{
super(context);
paint = new Paint();
}
protected void onDraw(Canvas canvas)
{
canvas.drawRGB(255, 255, 255);
paint.setColor(Color.RED);
canvas.drawLine(
0,
0,
canvas.getWidth()-1,
canvas.getHeight()-1,
paint);
paint.setStyle(Style.STROKE);
paint.setColor(0xff00ff00);
canvas.drawCircle(
canvas.getWidth()/2, //cx
canvas.getHeight()/2, //cy
40, //radius
paint);
paint.setStyle(Style.FILL);
paint.setColor(0x770000ff);
canvas.drawRect(100, 100, 200, 200, paint);
invalidate();
}
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
);
setContentView(new RenderView(this));
}
}
'코드조각모음' 카테고리의 다른 글
[android014] 트루타입 폰트 사용 예제 (0) | 2011.11.06 |
---|---|
[android013] 비트맵 그리기 (0) | 2011.11.06 |
[android011] 캔바스 예제 - 랜덤 색상 배경화면 (0) | 2011.11.06 |
[android010] 전체화면 예제 (0) | 2011.11.06 |
[android009] 배경음을 위한 MediaPlayer 예제 (1) | 2011.11.06 |