android gets the screen size

  • 2020-06-12 10:40:55
  • OfStack

Without further ado, I'll just hand in the code


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

Above is the code that this article shares to you, hope you can like.


Related articles: