Android2D Display size
When drawing something with Android2D, the important point is display size(canvas size).
To decide point to draw, and to arrange shapes in canvas, display size is important.
We have 2 types of size.
- Canvas size
- Display size
Which is better to use? Good question. But it depends on your settings.
Sample
Please check your results.
public class MultiLineDemoView extends View { private Paint paint; private int screenWidth; // width private int screenHeight; // height private static final String TAG = "MultiLineDemoView"; public MultiLineDemoView ( Context context ) { super(context); paint = new Paint(Paint.ANTI_ALIAS_FLAG); } @Override protected void onSizeChanged ( int w, int h, int oldw, int oldh ) { super.onSizeChanged(w, h, oldw, oldh); this.screenWidth = w; this.screenHeight = h; } @Override protected void onDraw ( Canvas canvas ) { canvas.drawColor(Color.BLACK); Log.d(TAG, "Width: " + screenWidth); Log.d(TAG, "Height: " + screenHeight); // just fit // Get Width and Height from canvas int canvasWidth = canvas.getWidth(); int canvasHeight = canvas.getHeight(); Log.d(TAG, "Canvas Width: " + canvasWidth); Log.d(TAG, "Canvas Height: " + canvasHeight); } }