【问题标题】:How to remove space in the gallery如何删除画廊中的空间
【发布时间】:2011-08-19 04:35:11
【问题描述】:

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

我也发布了我的代码:

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

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

【问题讨论】:

标签: android


【解决方案1】:

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

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

【讨论】:

  • 这将如何解决问题?它只是使每个画廊项目与屏幕一样宽,图像居中。
【解决方案2】:

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

【讨论】:

  • android:padding="15dip" 添加所有四个填充。只添加 paddingLeft 和 paddingRight
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-31
  • 1970-01-01
相关资源
最近更新 更多