Skip to content Skip to sidebar Skip to footer

Android Using Wrong Layout?

I need to create diffrent layouts for diffrent phones. I chekced 3 phones and screen sizes: SONY XPERIA Z: 08-30 09:04:05.258 1008-1008/pl.graphicbox.polamp I/LAYOUT: widthPixels

Solution 1:

looks like all phones have a width between 300 and 400 dp, and it is correct, when they use sw300dp. To check it, add the dpWidth to the log:

Display display = getWindowManager().getDefaultDisplay();
DisplayMetrics outMetrics = new DisplayMetrics ();
display.getMetrics(outMetrics);

float density  = getResources().getDisplayMetrics().density;
float dpWidth  = outMetrics.widthPixels / density;

Post a Comment for "Android Using Wrong Layout?"