Search code examples
androidbitmapdrawable

change bitmap size based device Android Studio


In android studio the return value of this function BitmapFactory.decodeResource(getResources(), R.drawable.basictiles) changes based on device size.

as and example

Pixel:

  • size = 1.792.000
  • height, width = 1120,400

SM-G900F

  • size = 2.580.480
  • height, width = 1344,480

I'm trying to find a way to get the same image size for every device/resolution.


Solution

  • put your R.drawable.basictiles file inside drawable-nodpi folder

    another approach is to use new BitmapFactory.Options() when decodeResource (third param) and set inScaled param to false