码迷,mamicode.com
首页 > 移动开发 > 详细

Android getMeasuredHeight()与getHeight()的区别

时间:2014-06-06 09:15:59      阅读:494      评论:0      收藏:0      [点我收藏+]

标签:des   android   c   style   class   blog   

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 getHeight ()

Added in API level 1

Return the height of your view.

Returns
  • The height of your view, in pixels.

getMeasuredHeight()返回的是原始测量高度,与屏幕无关,getHeight()返回的是在屏幕上显示的高度。实际上在当屏幕可以包裹内容的时候,他们的值是相等的,只有当view超出屏幕后,才能看出他们的区别。当超出屏幕后,getMeasuredHeight()等于getHeight()加上屏幕之外没有显示的高度。

 

例:

bubuko.com,布布扣
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="240dip"
    android:clipToPadding="false"
    android:scrollY="50dip" >

</RelativeLayout>
bubuko.com,布布扣

这里设置它的高度为240dip,超出屏幕50dip。

getMeasuredHeight()获得的就是240dip的大小。(转换为像素值)

getHeight()获得的是240dip - 50dip的大小。(转换为像素值)

Android getMeasuredHeight()与getHeight()的区别,布布扣,bubuko.com

Android getMeasuredHeight()与getHeight()的区别

标签:des   android   c   style   class   blog   

原文地址:http://www.cnblogs.com/x-dev/p/3767538.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!