If you want to display an image, but, unfortunately, this image is large, for example, you want to display an image in 30 by 30 format, then check its size if it is larger than your desired size, and then divide it by your total (30 * 30 here in this case), and what you got is again taken and used to divide the image area again.
drawable = this.getResources().getDrawable(R.drawable.pirImg); int width = drawable.getIntrinsicWidth(); int height = drawable.getIntrinsicHeight(); if (width > 30)
Pir fahim shah
source share