¿Por qué el lienzo no tiene el mismo tamaño que la vista en onDraw? (Androide)
Intenté con esto
@Override
protected void onDraw(Canvas canvas)
{
Log.e("TEST", "canvas width: " + canvas.getWidth() + "");
Log.e("TEST", "view width: " + this.getWidth() + "");
Log.e("TEST", "canvas height: " + canvas.getHeight() + "");
Log.e("TEST", "view height: " + this.getHeight() + "");
super.onDraw(canvas);
Log.e("TEST", "canvas width: " + canvas.getWidth() + "");
Log.e("TEST", "view width: " + this.getWidth() + "");
Log.e("TEST", "canvas height: " + canvas.getHeight() + "");
Log.e("TEST", "view height: " + this.getHeight() + "");
}
Y este es el resultado:
canvas width: 320
view width: 480
canvas height: 533
view height: 300
canvas width: 320
view width: 480
canvas height: 533
view height: 300
Parte de mi main.xml
android:layout_width="480px"
android:layout_height="300px"
Según mis impresiones de registro y parte de mi xml, el tamaño de la vista es correcto. Mi dispositivo es 480x800 y tanto el ancho como la altura divididos por los resultados de Log dan 1.5 (800/533 = 1.5 y 480/320 = 1.5), así que parece que obtengo Canvas de toda la pantalla para dibujar. ¿Por qué es esto, y por qué es tan pequeño y qué debo hacer para dibujar de manera normal?