代码设置LinearLayout的高度
====================问题描述====================
我想把这个LinearLayout宽度设置成为FILL_PARENT,源码如下
LinearLayout checkboxLinearLayout = (LinearLayout) getLayoutInflater().inflate(R.layout.checkboxdoitem, null);
LayoutParams params= (LayoutParams) checkboxLinearLayout.getLayoutParams();
params.width=LayoutParams.FILL_PARENT;
checkboxLinearLayout.setLayoutParams(params);
红色处报错,log是下图
====================解决方案1====================
params 为空?
====================解决方案2====================
params为空值,没获取到
====================解决方案3====================
checkboxLinearLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
还不如写在xml里呢