【发布时间】:2012-11-20 03:55:14
【问题描述】:
我已经为此花费了数小时,并查看了我可以找到的所有相关 SO 问题,但没有解决方案。
这是我的问题:
我有一个图像网格视图。我需要 3 列(以匹配 iOS 版本和美学)。如果我将 numColumns 设置为 3,我会在每一行的图像行的顶部和底部之间获得很多额外的空间。如果我将宽度设置为自动调整,我总是得到 2,它们看起来更好,但更喜欢 3 列。
我错过了什么?
布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="top" >
<LinearLayout
android:id="@+id/llayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
>
<ImageView
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#666666"
android:clickable="false"
android:contentDescription="@string/title_card_collection"
android:src="@drawable/sportscard2x" />
</LinearLayout>
<GridView
android:id="@+id/cardGrid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_above="@+id/llayout"
android:gravity="center"
android:horizontalSpacing="2dip"
android:numColumns="3"
android:stretchMode="columnWidth"
android:layout_alignParentBottom="true"
android:verticalSpacing="2dip" >
</GridView>
我希望我只是想念一些简单的事情。提前致谢。
更新:添加截图。问题是只显示了 1 行,如果向下滚动,您会看到其他 3 行,但中间有很大的空间。
【问题讨论】:
-
这根本没有帮助。更新以显示更多 XML
-
你能张贴你想要的结果的截图或模型吗?你现在有什么。我刚刚用了三列的gridView,没有任何问题
-
我检查了您的布局,它按照您的期望工作正常。
-
添加了图片。希望这更清楚。我需要它来显示所有行。 (类似于图库)