SoFunction
Updated on 2025-04-10

android get screen size

Don't say much nonsense, just present the code

Copy the codeThe code is as follows:

DisplayMetrics dm = new DisplayMetrics();
                getWindowManager().getDefaultDisplay().getMetrics(dm);
int width = ;  // Screen width (pixel)
int height = ;  // Screen height (pixel)
                (this,  width+":"+height, Toast.LENGTH_LONG).show();

The above is the code shared by this article, I hope you like it.