2011-08-19 67 views
1

我有两个画廊。图片库和一个文本画廊分开。两个画廊的开始和结束都有空间。所有的都是相对的布局。我不明白是什么问题。请帮忙。如何删除画廊中的空间

我已经发布我的代码也:

 <?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> 

我在开始和画廊鉴于年底空间。

+0

你可以发布你的布局xml。你必须编辑你的问题并添加布局细节。 – Samuel

+1

请发布您的布局xml。 – Ronnie

+0

检查这些链接, 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

回答

0

我想这是因为android:gravity =“center_horizo​​ntal”。此外android:padding =“15dip”添加了所有四个填充。只添加paddingLeft和paddingRight。

+0

不,我也尝试过..也有任何其他方法? – preeti

+0

android:padding =“15dip”添加所有四个填充。只添加paddingLeft和paddingRight – superM

0

为了解决这个问题,我通常会以编程方式更改LayoutParams。一旦你在getView()中有你的ImageView(在这个例子中称为iv),你可以这样做:

iv.setLayoutParams(new Gallery.LayoutParams(Gallery.LayoutParams.FILL_PARENT, Gallery.LayoutParams.FILL_PARENT)); 
iv.setScaleType(ScaleType.FIT_CENTER); 
+0

这将如何解决问题?它只是使每个画廊项目与屏幕一样宽,图像居中。 – Maragues