大神在哪里啊params.width直接设置为50也报错啊

解决方案 »

  1.   

    这个是checkboxdoitem的xml
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical" >    <CheckBox
            android:id="@+id/checkBoxItem1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/></LinearLayout>
      

  2.   


    inflate 出来的View 没add到显示的布局中之前,布局参数是获取不到的。
      

  3.   

     checkboxLinearLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));还不如写在xml里呢
      

  4.   

    我在LinearLayout动态添加这个checkboxdoitem,xml内容我上面发了,我想自动换行,结果都在一行,我就想4个一行,强行的设置第四个的宽度为fill_parent,可是效果还是都在一行,不会设计这个android视图,怎么破
      

  5.   

    LayoutParams params= (LayoutParams) checkboxLinearLayout.getLayoutParams();//没有set先get所以获取的是null
    应该
    checkboxLinearLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));