Saturday, 31 August 2013

Strange issues with a new device creation in AVD for motorola razr (540x960)

Strange issues with a new device creation in AVD for motorola razr (540x960)

I have been testing my xml layouts for multiple screen sizes using Android
emulator. I created a new device in the AVD for Motorola Razr (Resolution:
540x960), size (in inch) = 4.3, hdpi.
Strangely enough, the metrics.height comes out to be 888 instead of 960,
whereas metrics.width is correct (=540).
DisplayMetrics metrics = new DisplayMetrics();
this.getWindowManager().getDefaultDisplay().getMetrics(metrics);
Log.i("widthPx: ", ""+metrics.widthPixels); // comes out 540
Log.i("heightPx", ""+metrics.heightPixels); // comes out 888 ?? How come ??
Now, my problem is how do I rely on this virtual device while testing my
layouts. I also created a new AVD with the resolution 540x1032 whose width
& height comes out to be exactly 540x960 programmatically (intentionally
added 88px to 960px (==1032) to get the desired height). Should i rely on
this device instead? I'm confused.
Also i double checked that every details in my AVD are correctly entered.
Please help if anyone has ever faced a similar situation.

No comments:

Post a Comment