Skip to content

Instantly share code, notes, and snippets.

@wowiwo1
Last active September 20, 2015 13:17
Show Gist options
  • Save wowiwo1/327ba968ef278fc0bce7 to your computer and use it in GitHub Desktop.
Save wowiwo1/327ba968ef278fc0bce7 to your computer and use it in GitHub Desktop.
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new MainView(this));
}
private class MainView extends View {
public MainView(Context context) {
super(context);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawColor(Color.WHITE);
Paint paint = new Paint();
paint.setColor(Color.RED);
canvas.drawCircle(
canvas.getWidth()/2,
canvas.getHeight()/4,
canvas.getHeight()/10,
paint);
paint.setColor(Color.GREEN);
paint.setStyle(Paint.Style.STROKE);
canvas.drawRect(
canvas.getWidth()/2 - canvas.getHeight()/10,
canvas.getHeight()*2/4 - canvas.getHeight()/10,
canvas.getWidth()/2 + canvas.getHeight()/10,
canvas.getHeight()*2/4 + canvas.getHeight()/10,
paint);
paint.setColor(Color.BLUE);
paint.setStyle(Paint.Style.FILL);
paint.setAntiAlias(true);
canvas.drawCircle(canvas.getWidth()/2,
canvas.getHeight()*3/4,
canvas.getHeight()/10,
paint);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment