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;
source
share