I am working with canvas in android. i want to draw shapes on canvas which fits in every screen.
if screen size is 320 * 240 then height & width with is 90 * 90 but
if screen_size is > 320 * 240 then it should increase accordingly.
Suppose screen_size = 1280 * 800 then how much it should increase
I don't know what to do for this
Code is Like
int fixHeight = 240, fixWidth = 320;
Paint paint;
paint = new Paint();
paint.setColor(Color.GREEN);
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int height = displaymetrics.heightPixels;
int width = displaymetrics.widthPixels;
@Override
protected void onDraw(Canvas canvas) {
if (height <= fixHeight && width <= fixWidth) {
canvas.drawRect(10, 10, 50, 50, paint);
} else {
// Don't Know What TO Put Here
}
}
Can any one help me