我想要的是让 gridview 填满整个屏幕。当你向下滚动它时,最后会出现一个带有 2 个按钮的布局。我一直在阅读,但不知道如何获得它。我可以将它固定在屏幕顶部和底部(在 gridview 上方)。并且在填充 gridview 时甚至不会出现带有按钮的布局。
我一直在玩重量、对齐等。但找不到问题所在。这是 xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/fondo">
<GridView android:layout_width="fill_parent"
android:id="@+id/gridView1"
android:layout_height="wrap_content"
android:numColumns="2"
android:listSelector="#00000000">
</GridView>
<LinearLayout android:id="@+id/linearLayout"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:layout_below="@id/gridView1">
<ImageView android:id="@+id/botonAtras"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="1"
android:onClick="onBotonAtrasClick">
</ImageView>
<ImageView android:id="@+id/botonAdelante"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="1"
android:onClick="onBotonAdelanteClick">
</ImageView>
</LinearLayout>
</RelativeLayout>
最佳答案
据我所知,您无法轻易做到这一点。您可以使用 addFooter()
使用普通 ListView
来完成此操作,但遗憾的是 GridView
没有此方法。此外,您不能实现自己的 GridView
,因为它使用了很多私有(private) API。
但是,这里使用了一个可能有用的可怕 hack:Android Pull to refresh
显然它使用了包含标题 View 和 ListView
的 LinearLayout
并将它们都移动了。 (根据 this page 。)正如那个人所说,为一个可怕的骇人听闻的黑客做了大量的工作。
我能想到的唯一其他方法是放弃 GridView
并使用 ListView
,其中每一行都是水平的 LinearLayout
。不过仍然很老套。
关于Android:布局在 gridview 的底部(在它的末尾),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7596765/