what does android getIntrinsicHeight and getIntrinsicWidth mean?

前端 未结 3 400
旧巷少年郎
旧巷少年郎 2020-12-23 13:19

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

getIntrinsicHeight()
getIntrinsicWidth()

api definition says http://develo

3条回答
  •  悲哀的现实
    2020-12-23 14:01

    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.

提交回复
热议问题