1 int width = ScreenUtils.getScreenWidth(this); 2 int height = ScreenUtils.getScreenHeight(this); 3 mImageView = new ImageView(this); 4 mImageView.setScaleType(ImageView.ScaleType.FIT_XY); 5 mImageView.setLayoutParams(new Gallery.LayoutParams(width, height));// 设置Gallery组件的背景风格
1 ViewGroup.LayoutParams params = mImageView.getLayoutParams(); 2 //设置图片的相对于屏幕的宽高比 3 params.width = width; 4 params.height = height; 5 mImageView.setLayoutParams(params);