两种方法:
//第一种: LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, 100); //第一个参数是宽,第二个参数是高 LinearLayout test_layout = (LinearLayout) findViewById(R.id.testlayout); test_layout.setLayoutParams(lp); //第二种 LinearLayout test_layout = (LinearLayout) findViewById(R.id.testlayout); // 这里的LayoutParams 导包要导 android.view.ViewGroup.LayoutParams; LayoutParams lp = test_layout.getLayoutParams(); lp.height = 100;