我花了好几个小时的时间,看了没有解决方案时找到的每个相关的SO问题。Android GridView不能正确缩放
这里是我的问题:
我有图像的GridView控件。我需要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行,但中间有一个巨大的空间。
参考这个答案http://stackoverflow.com/questions/12363106/gridview-height-is-too-tall-when-using-an-imageview-inside/12363218#12363218 –
这并没有帮助。已更新以显示更多的XML – RiddlerDev
您可以发布截图或想要的结果样机吗?你现在有什么。我刚刚使用了三列的gridView,没有任何问题 – Jin35