Gallery图像重叠问题以及每屏只显示一张
Android Gallery呈现图像的时候图像之间是有重叠的,不过在layout配置Gallery时配置android:spacing即可解决,比如:android:spacing="10sp".
至于每屏只显示一张图片,只要在Adapter中重写getView时候设置LayoutParams即可解决,比如:
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
ImageView i = new ImageView(mContext);
i.setImageResource(mImageIds[position]);
//设置样式 :填充整个屏幕
i.setLayoutParams(new Gallery.LayoutParams(Gallery.LayoutParams.FILL_PARENT,
Gallery.LayoutParams.FILL_PARENT));
//设置缩放样式:将图片的内容完整居中显示,通过按比例缩小或原来的size使得图片长/宽等于或小于View的长/宽
i.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
return i;
}
效果如下:
![gallery gallery](http://shanbei.info/wp-content/uploads/2012/03/device-2012-03-13-102506-180x300.png)