Android中动态设置布局高度一致

//设置高度一致
LinearLayout layoutEdit = (LinearLayout) findViewById(R.id.layoutEdit);//设置的布局
LinearLayout layoutSpinner = (LinearLayout) findViewById(R.id.layoutSpinner);//样例布局
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) layoutSpinner.getLayoutParams();
int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
layoutSpinner.measure(w, h);
int IconHeight = layoutSpinner.getMeasuredHeight();
params.height = IconHeight;
layoutEdit.setLayoutParams(params);

你可能感兴趣的:(Android)