0

I'm having problems with images on android, I need to create one image that have the same size in different devices but I don't know how I calculate this using DisplayMetrics.

How can I set the same size in different width and DPI devices?

gFontaniva
  • 897
  • 11
  • 27

3 Answers3

3

Short answer: use an amount of dp (density independent pixels) as width and it should look the same on different devices.

To get a better understanding of screen sizes I would recommend reading this article from Google Developers https://developer.android.com/guide/practices/screens_support.html

Sander
  • 808
  • 6
  • 18
1

I think you mean using "in" (inch) instead of dp/dip and worth to know those differences between measurements in android from this question

Community
  • 1
  • 1
Dasser Basyouni
  • 3,142
  • 5
  • 26
  • 50
1

If you want to display the image in same size in different devices, perhaps you should use Imageview for that, it will show you the image exactly in same size and position in every device.

Ranjan
  • 1,326
  • 18
  • 38