动态创建一个Button, Button btn = new Button( this );
如果设置它的 android:layout_weight 属性
------解决方案--------------------
看看这个对不对
Button button = new Button(this);
LinearLayout.LayoutParams ly = new LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT);
ly.weight = 0;
button.setLayoutParams(ly);