XML中Android Gallery的开头没有空格

时间:2013-11-26 12:38:28

标签: android android-layout

尝试使用Gallery组件做一个简单的事情(默认由系统提供)。我可以显示图像,但尽管我很难显示没有填充/边距的画廊...所以我可以在屏幕的整个宽度上看到画廊它不起作用。

这是我的代码:

         <TableRow
                android:id="@+id/screenshotRow"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="left"
                android:layout_marginBottom="10dp"
                android:padding="0dp" >

                <Gallery
                    android:id="@+id/screenshotGallery"
                    android:layout_width="fill_parent"
                    android:layout_height="200dp"
                    android:horizontalSpacing="5dp"
                    android:scaleType="fitXY"
                    android:spacing="3dip"
                    android:stretchMode="columnWidth"
                    android:verticalSpacing="5dp" />
            </TableRow>

我不明白为什么这不起作用。我也在google上搜索过,发现这个问题发生但不明白是什么解决方案。很多人建议使用水平滚动列表..

是否有可能摆脱android gallery组件开头的空间? 谢谢。

1 个答案:

答案 0 :(得分:1)

  1. 图库是已弃用的组件。您应该使用ViewPager(它是支持库的一部分)或类似的组件。
  2. “fill_parent”for android:layout_width是不推荐使用的参数。使用 match_parent 代替
  3. 我没有得到这个“尽管我努力展示没有填充/边距的画廊”,然后在代码中你将margin_bottom设置为10dp,horizo​​ntalSpacing为5dp,verticalSpacing为5dp,间距为3dp?!?你的空间有问题。 o.O

  4. 不确定为什么你要把画廊放在一排!?!行应该在表内使用,就像这样。相关布局内的图库将在全屏显示。这就是它应该如何完成的。由于stackoverflow上的奇怪格式错误,我正在与您分享Gallery inside RelativeLayout xml code here

    <Gallery
        android:id="@+id/screenshotGallery"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    
  5. 希望这有助于你;)干杯