Hi all,
I will try to be as clear as possible.
Here What I am trying to do
An Image Viewer, where Image would be display as big as they can on the device screen. For this purspose and for a better user experience, I thought of a Gallery. Untill there everything is OK!
The problem
The problem is that in the function getView of my Adapter, it uses only the Gallery.LayoutParams of the first Image I have in my Gallery. Which means that if the first picture is a landscape and the second one a portrait the second one will be display as landscape, with the same dimension as the first one. I do reset the Gallery.LayoutParams but it does not matter, it still have the LayoutParams of the first ImageView.
The code
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,