what does android getIntrinsicHeight and getIntrinsicWidth mean?

user1697965 picture user1697965 · Dec 7, 2012 · Viewed 36.2k times · Source

Hi I am confused by the two methods from Android Drawable class

getIntrinsicHeight()
getIntrinsicWidth()

api definition says http://developer.android.com/reference/android/graphics/drawable/Drawable.html#getIntrinsicHeight()

what does the word intrinsic height/width mean? i mean is it a width of the actual image?

Answer

Andro Selva picture Andro Selva · Dec 7, 2012

If you want to know the meaning of intrinsic, it is nothing but the actual property possessed by an object. In our case getIntrinsicWidth/Height simply means to provide you with the default width/height of that drawable.

This returns the exact size of the drawable which you have put in the resource folder without any modification.

Now you have to know that getWidth or getHeight will return a value which might vary according to the width and height you specify for your ImageView in your XML layout.

Let's say that you have provided the width and height of your ImageView as 100*100 in the XML layout and the drawable you used as the background is of size 200*200.

Now getIntrinsicWidth must return 200 whereas getWidth must return 100.