I got the following problem , i made a form with a gallery, the gallery instead of containing images contains items from one of my classes, everything inside each item of the gallery displays perfectly. I removed the space between images using:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Gallery android:id="@+id/galleryid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:spacing="0dip"
android:padding="0dip"
android:layout_weight="1" />
the items of the gallery:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="75dip" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:orientation="vertical" android:gravity="center_horizontal" android:background="#ffffff">
<TextView android:id="@+id/frame_number" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="-" android:textSize="12dip" android:textColor="#ffffff" android:background="#000000" android:gravity="center" />
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="horizontal" android:gravity="center_horizontal">
<TextView android:id="@+id/frame_shot1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="-" android:textSize="18dip" android:textColor="#000000" />
<TextView android:id="@+id/frame_shot2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="-" android:textSize="18dip" android:textColor="#000000" />
</LinearLayout>
<TextView android:id="@+id/frame_total" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="---" android:textSize="38dip" android:textColor="#000000"/>
</LinearLayout>
buuuuuuuuuuuuuuuuut , i got a problem, there is some blank space at the beginning and end of the gallery with no items. the thing is that my gallery has many items on it that u can actually scroll horizontally, but i wanna get rid of those spaces so the very first thing on the very left of the gallery is the first item, and the very last when u scroll to the very right is the right item.
Edit 08/16 Still with the same problem back in the project, here i leave an image of exactly what is what I'm trying to get rid of that is the black space at the beginning (also is at the end of the gallery at the other side)
The reason you get the blank space on the left is simply because there are no more items to display to the left of the first item (centred in the view). I would assume that the same problem arises to the right of the last item as well.
To properly solve this one will have to decide on what to display when there are no more items, but I will give some ideas:
(1) Increasing the width of the gallery items to the same width as the gallery will only show one item at a time, thus the user will never be able to scroll to the empty space.
(2) To display a solid color or an image in the blank space I would assume setting the android:background attribute of the gallery.
(3) Create a buffer in the beginning and end of your adapter, consisting of the last/first items respectively, and when the user scrolls far enough in the buffer, jump to the matching item at the other end of the gallery for a infinite "carousel" gallery.