以下理解均为错误,因为LayoutParams是属于ViewGroup的,对于一个ViewGroup中的子元素,可以用该ViewGroup的LayoutParams
GridView和Gallery中都有LayoutParams为他们的子View设置参数
ImageView imageView=new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(50, 50));
imageView.setImageResource(mImageIds[position]);
关于普通View设置参数的办法为
LayoutParams params = viewgroup.getLayoutParams();
params.height=50;
params.width=50;
viewgroup.setLayoutParams(params);
以上的LayoutParams是引自ViewGroup的
以上理解均为错误,因为LayoutParams是属于ViewGroup的,对于一个ViewGroup中的子元素,可以用该ViewGroup的LayoutParams