一般动态设置VIew宽高的写法是:
View child = new View(this);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) child.getLayoutParams();
layoutParams.width = 120;
layoutParams.height = 120;
child.setLayoutParams(layoutParams);
这里需要注意的是:LayoutParams所导的包应该是这个VIew的父布局所对于的类型,也就是说如果包裹这个View的是LinearLayout,那就应该导LinearLayout,是RelativeLayout就应该导入RelativeLayout,否则运行会出错,类型转换异常java.lang.ClassCastException: