问题描述
我对Android Drawable类中的两种方法感到困惑
Hi I am confused by the two methods from Android Drawable class
getIntrinsicHeight()
getIntrinsicWidth()
api定义为
http://developer.android.com/reference/android/graphics/drawable/Drawable.html#getIntrinsicHeight()
固有高度/宽度是什么意思?
i表示它是实际图像的宽度吗?
what does the word intrinsic height/width mean?i mean is it a width of the actual image?
推荐答案
如果您想了解的含义,内在,它不过是对象拥有的实际属性。在我们的例子中, getIntrinsicWidth / Height
只是意味着为您提供该可绘制对象的默认宽度/高度。
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.
现在您必须知道 getWidth
或 getHeight
将返回一个值,该值可能会根据您在XML布局中为 ImageView
指定的宽度和高度而有所不同。
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.
假设您提供了 ImageView
的宽度和高度为 100 * XML布局中为100
,用作背景的可绘制对象的大小为200 * 200。
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.
现在 getIntrinsicWidth
必须返回200,而 getWidth
必须返回100。
Now getIntrinsicWidth
must return 200 whereas getWidth
must return 100.
这篇关于android getIntrinsicHeight和getIntrinsicWidth是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!