- public final int getMeasuredHeight ()
Added in API level 1
Like getMeasuredHeightAndState(), but only returns the raw width component (that is the result is masked by MEASURED_SIZE_MASK).
Returns:
The raw measured height of this view.
- public final int getMeasuredHeightAndState ()
Added in API level 11
Return the full height measurement information for this view as computed by the most recent call to measure(int, int). This result is a bit mask as defined by MEASURED_SIZE_MASK and MEASURED_STATE_TOO_SMALL. This should be used during measurement and layout calculations only. Use getHeight() to see how wide a view is after layout.
Returns:
The measured width of this view as a bit mask.
- public final int getHeight ()
Added in API level 1
Return the height of your view.
Returns:
The height of your view, in pixels.
以上3個View類的方法中,前兩個是一類的,只不過返回的數據形式不一樣。對比這兩類,
- getMeasuredHeight
返回控件的實際高度;
- getHeight
返回控件在屏幕中的高度
所以如果控件可以包裹在屏幕內的話,兩個函數的返回值相同,而一旦view過大,則getMeasuredHeight()等於getHeight()加上屏幕之外沒有顯示的高度。