见下面的布局。我无法将页脚按钮放在 GridView
下方。
任何帮助将不胜感激。
Gridview填屏时Button不显示。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<GridView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:columnWidth="90dp"
android:gravity="center"
android:horizontalSpacing="10dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp" />
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/gridview"
android:text="Load More Images" />
</RelativeLayout>
最佳答案
我一直在寻找 GridView 很长时间,它允许我们像 ListView
一样addFooterView
和addHeaderView
。
两年前的帖子了。我是通过谷歌搜索结果中的链接来到这里的。我不知道这个问题是否已经解决。
如果没有,这里有一个库可能会有帮助。 https://github.com/liaohuqiu/android-GridViewWithHeaderAndFooter .
很简单:
GridViewWithHeaderAndFooter gridView = (GridViewWithHeaderAndFooter) v.findViewById(R.id.ly_image_list_grid);
LayoutInflater layoutInflater = LayoutInflater.from(this);
View headerView = layoutInflater.inflate(R.layout.test_header_view, null);
View footerView = layoutInflater.inflate(R.layout.test_footer_view, null);
gridView.addHeaderView(headerView);
gridView.addFooterView(footerView);
这是一个屏幕快照:
希望这会有所帮助。祝你好运!
关于android - 需要在 Android 中为 Gridview 创建页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8876596/