1

I have two galleries.image gallery and a text gallery seperately.There is space at the beginning and end of both the galleries.All are in relative layout.I dont understand what is the problem.Please help.

I have posted my code also:

     <?xml version="1.0" encoding="utf-8"?>
        <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/main"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
            >

    <TextView android:text="Airing Now" 
    android:id="@+id/titletextview" 
    android:textSize="22dip"
    android:textColor="@color/textcolor"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content">
    </TextView>


    <Gallery
    android:id="@+id/Gallery_image" 
    android:layout_below="@+id/titletextview"
    android:spacing="15dip"
android:padding="15dip"

    android:layout_width="fill_parent" 
    android:layout_height="wrap_content">
    </Gallery>

    <ImageView android:id="@+id/ImageView"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content">
    </ImageView>

     <Gallery
        android:id="@+id/gallery_text"
        android:layout_below="@+id/Gallery_image"
        android:layout_width="fill_parent" 
        android:layout_height="match_parent"
         />
    </RelativeLayout>

I have space at the beginning and end of gallery view.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
preeti
  • 11
  • 3
  • could you post your layout xml. you have to edit you question and add the layout details. – Samuel Aug 19 '11 at 04:38
  • Check these links, http://stackoverflow.com/questions/6606547/how-to-avoid-spacing-in-the-start-and-end-of-gallery http://stackoverflow.com/questions/6752310/gallery-space-at-beginning-and-end – Randroid Aug 19 '11 at 05:31
  • hi thanks..i checked these links but it not working... – preeti Aug 19 '11 at 06:58

2 Answers2

0

I guess that's because android:gravity="center_horizontal". Also android:padding="15dip" adds all four paddings. Add only paddingLeft and paddingRight.

superM
  • 8,605
  • 8
  • 42
  • 51
0

To combat this I usually change the LayoutParams programatically. Once you have your ImageView (in this instance called iv) in getView() you can do:

iv.setLayoutParams(new Gallery.LayoutParams(Gallery.LayoutParams.FILL_PARENT, Gallery.LayoutParams.FILL_PARENT));
iv.setScaleType(ScaleType.FIT_CENTER);
Ljdawson
  • 12,091
  • 11
  • 45
  • 60
  • How would that fix the problem? It simply makes each gallery item as wide as the screen, with the image centered. – Maragues Nov 08 '11 at 12:22