views:

338

answers:

1

I have a Gallery with a set of images that was downloaded at run time.

I followed the example here: http://www.anddev.org/a_androidwidgetgallery_-_example-t332.html

but instead of using

i.setImageResource(this.myImageIds[position]);

I used

i.setImageBitmap(bitmaps.get(position));

This doesn't fill the entire width of the screen, only as much as the width specified here:

i.setLayoutParams(new Gallery.LayoutParams(150, 150)); 

When I increase this number, the item scales with it instead of showing more images per the example. I've even tried to scale the images before adding them to the set. Not sure what I'm missing, or where other examples of this might be. Any help would be great, Thanks.

A: 

Hi Erik! In your layout xml file be sure to set android:layout_width="fill_parent", like this

<Gallery 
            android:id="@+id/gallery"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="2dip"
                        android:layout_gravity="center_horizontal|bottom"
                        android:padding="1dip"
                        android:background="#AA000000"
            />
southerton