我会尽量说清楚。
Here What I am trying to do
For this purspose and for a better user experience, I thought of a Gallery.
Untill there everything is OK!
问题
问题是,在适配器的getview函数中,它只使用我在库中的第一个图像的gallery.layoutParams。也就是说,如果第一张图片是一幅风景画,而第二张图片是一幅肖像画,那么第二张图片将显示为风景画,与第一张图片的尺寸相同。我确实重置了gallery.layoutParams,但这并不重要,它仍然具有第一个ImageView的layoutParams。
代码
public View getView(int position, View convertView, ViewGroup parent) {
ImageView im = new ImageView(mContext);
Bitmap bm = BitmapFactory.decodeByteArray(gallery.get(position).mContent, 0, gallery.get(position).mContent.length);
im.setImageBitmap(bm);
int width = 0;
int height = 0;
if (bm.getHeight() < bm.getWidth()) {
width = getWindowManager().getDefaultDisplay().getWidth();
height = bm.getHeight() * width / bm.getWidth();
}
else {
height = getWindowManager().getDefaultDisplay().getHeight();
width = bm.getWidth() * height/ bm.getHeight();
}
Gallery.LayoutParams lp = new Gallery.LayoutParams(width, height);
im.setLayoutParams(lp);
return im;
}
If any of you see why I would be really please to know the answer,