如何删除库中的空间

时间:2011-08-19 04:35:11

标签: android

我有两个画廊。图像画廊和一个文本画廊。画廊的开头和结尾都有空间。所有都是相对布局。我不明白是什么问题。请帮忙。

我也发布了我的代码:

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

我在画廊视图的开头和结尾都有空格。

2 个答案:

答案 0 :(得分:0)

我想那是因为android:gravity =&#34; center_horizo​​ntal&#34;。还有android:padding =&#34; 15dip&#34;添加所有四个填充。只添加paddingLeft和paddingRight。

答案 1 :(得分:0)

为了解决这个问题,我通常以编程方式更改LayoutParams。在getView()中使用ImageView(在本例中称为iv)后,您可以执行以下操作:

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