Display Issue in GridView (layout inflator) having button at the bottom of the screen?
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?
Try This New Code I updated it and Checked also .........
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout android:id="@+id/rl1" android:layout_width="wrap_content" android:layout_height="wrap_content">
<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" android:layout_above="@+id/button"/>
<Button android:layout_width="fill_parent" android:id="@+id/button" android:paddingTop="5dp" android:layout_height="wrap_content" android:text="submit" android:layout_alignParentBottom="true"></Button>
</RelativeLayout>
</merge>
Try to include both your gridview and the relative view in another RelativeView
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/outer_container" > <GridView 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" android:layout_alignBelow="id/sdcard"> <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>
</RelativeLayout>
</merge>
OR you can simply put both the GridView and your button into one RelativeView
Use ConstraintLayout Like this
<GridView
android:id="@+id/grid_view"
android:padding="0dp"
android:columnWidth="90dp"
android:gravity="center"
android:horizontalSpacing="10dp"
android:numColumns="2"
android:stretchMode="columnWidth"
android:verticalSpacing="50dp"
android:layout_marginBottom="1dp"
android:layout_width="368dp"
android:layout_height="551dp"
tools:layout_editor_absoluteY="8dp"
tools:layout_editor_absoluteX="8dp" />
精彩评论