I already did some research on that question, found some topic but nothing that helped me.
This is what I have :
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<GridView
android:id="@+id/grid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="2"
android:padding="5dp"/>
<EditText
android:id="@+id/edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"/>
</RelativeLayout>
The problem I have is that when there are too many elements in my grid, the edittext is pushed off the screen. I tried to use alignParentBottom on the editText but this is not what I want.
I was wondering if there is any way to keep the edit text always visible even if there are many elements in the grid view AND to keep the edit text below the grid and not aligned bottom with the parent. I also tried to use a scroll view instead of the relative layout... but this is wrong too cause there are too many bugs using a grid view inside a scroll view.
I hope that I'm clear, don't hesitate to ask for more information.
Thanks you
You can achieve this with a simple LinearLayout
too:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<GridLayout
android:id="@+id/grid"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:numColumns="2"
android:padding="5dp" />
<EditText
android:id="@+id/edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:padding="5dp" >
<requestFocus />
</EditText>
</LinearLayout>
I've experienced LinearLayout
to be faster and more robust then RelativeLayout
but that's more kind of personal opnion.
This should do your job.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<GridView
android:id="@+id/grid"
android:layout_width="match_parent"
android:numColumns="2"
android:layout_height="0dp"
android:layout_weight="8"
android:padding="5dp"/>
<EditText
android:id="@+id/edit"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@+id/grid"
android:layout_weight="2"
android:padding="5dp"/>
</RelativeLayout>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.