void measureChild(View child){
ViewGroup.LayoutParams params = child.getLayoutParams();
if(params == null){
params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);
}
int childWidthSpec = ViewGroup.getChildMeasureSpec(0, 0 + 0,
params.width);
int lpHeight = params.height;
int childHeightSpec;
if (lpHeight > 0) {
childHeightSpec = View.MeasureSpec.makeMeasureSpec(lpHeight,
View.MeasureSpec.EXACTLY);
} else {
childHeightSpec = View.MeasureSpec.makeMeasureSpec(0,
View.MeasureSpec.UNSPECIFIED);
}
child.measure(childWidthSpec, childHeightSpec);
int measureWidth = child.getMeasuredWidth();
int measureHeight = child.getMeasuredHeight();
Log.d(TAG, "measureChild: "+"measureWidth="+measureWidth+" ,measureHeight="+measureHeight);
}
转载自:http://blog.csdn.net/loongggdroid/article/details/9385535