The emulator does not return the actual width and height for a resolution of 320x240

I made a dynamic layout application for different screen sizes.

It also worked for all screen sizes except 320x240 screens .

I used the same code to get the width and height for everyone, and it also returns the correct value, but it does not return the correct value for manually creating the 320x240 and 240x400 emulation tools .

I used the following code:

DisplayMetrics metrics = new DisplayMetrics();
WindowManager manager = (WindowManager)getSystemService(Context.WINDOW_SERVICE);

manager.getDefaultDisplay().getMetrics(metrics);

int width=metrics.widthPixels;
int height=metrics.heightPixels;
+5
source share
1 answer

I was late ... but would like to share :)

Try below code snippets:

 Display display = getWindowManager().getDefaultDisplay();

 int   width = display.getWidth();
 int   height = display.getHeight();         
0
source

All Articles