GridView(布局充气器)中的显示问题在屏幕底部有按钮?
我使用带有布局充气器的 gridview 来显示带有文本的图标,不同之处在于我必须在屏幕底部提供一个按钮。我的布局文件如下所示:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sdcard" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:verticalSpacing="10dp"
android:horizontalSpacing="10dp" android:numColumns="3"
android:stretchMode="columnWidth" android:gravity="center" android:background="#ffffff"/>
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent">
<Button android:text="submit" android:id="@+id/button"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:paddingTop="5dp">
</Button>
</RelativeLayout>
</merge>
当我在模拟器上测试它时(大小根据真实设备而定)。网格视图已正确填充,但当我滚动到最后一行时,图像可见,但文本和按钮阻碍了视图。我希望文本也可见。我怎样才能实现这个目标?
I am using gridview with layout inflator to display icon with text with the difference that I have to provide a button at the bottom of the screen. My layout file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sdcard" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:verticalSpacing="10dp"
android:horizontalSpacing="10dp" android:numColumns="3"
android:stretchMode="columnWidth" android:gravity="center" android:background="#ffffff"/>
<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent">
<Button android:text="submit" android:id="@+id/button"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:paddingTop="5dp">
</Button>
</RelativeLayout>
</merge>
When I test it on the emulator (size according to the real device). Grid view is correctly populated but when I scroll to the last row the image is visible but not the text and button is hindering the view. I want the text to visible also. How can I achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试这个新代码我更新了它并也检查了…………
Try This New Code I updated it and Checked also .........
尝试将您的 gridview 和相对视图都包含在另一个相对视图中
,或者您可以简单地将 GridView 和您的按钮放入一个相对视图中
Try to include both your gridview and the relative view in another RelativeView
OR you can simply put both the GridView and your button into one RelativeView
使用约束布局
像这样
Use ConstraintLayout
Like this