safe_content在布局中是高度是包裹内容
android:id="@+id/safe_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
在代码中
safe_content = (LinearLayout) view.findViewById(R.id.safe_content);
LayoutParams layoutParams = safe_content.getLayoutParams();
layoutParams.height = 0;
safe_content.setLayoutParams(layoutParams);
测量控件safe_content 高度
测量前
System.out.println("width====================="+safe_content.getMeasuredWidth());//等于344
System.out.println("height====================="+safe_content.getMeasuredHeight());//等于0
测量后
int widthMeasureSpec=MeasureSpec.makeMeasureSpec(MeasureSpec.EXACTLY, width);
int heightMeasureSpec=MeasureSpec.makeMeasureSpec(MeasureSpec.AT_MOST, 1000);//最大1000
safe_content.measure(widthMeasureSpec, heightMeasureSpec); // 通过该方法重新测量控件
System.out.println("width====================="+safe_content.getMeasuredWidth());//等于344
System.out.println("height====================="+safe_content.getMeasuredHeight());//等于135
那么问题来了,重新测量后为什么高度等于135,而不是0,它测的高度指的是什么
,不是当前设置layoutParams.height = 0;的高度吗,难道是在布局中 android:layout_height="wrap_content"的高度,测量控件测量的是什么的高度?