- 获取控件的宽高的靠谱方式:
final View viewGroup = mInflater.inflate(R.layout.view_cam_pop, null);
int w = View.MeasureSpec.makeMeasureSpec(0,
View.MeasureSpec.UNSPECIFIED);
int h = View.MeasureSpec.makeMeasureSpec(0,
View.MeasureSpec.UNSPECIFIED);
viewGroup.measure(w, h);
int height = viewGroup.getMeasuredHeight();// not 0
int width = viewGroup.getMeasuredWidth();// not 0