Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing Button Placed after ListView

I have a layout with 3 button at the top in a row and then a ListView followed by a button below the listView. This is my layout.xml file

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <Button android:id="@+id/btn_top10"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TOP 10"/>

    <Button android:id="@+id/btn_top100"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TOP 100"
        android:layout_toRightOf="@id/btn_top10"/>

    <Button android:id="@+id/btn_showAll"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Show All"
        android:layout_toRightOf="@id/btn_top100"/>

    <ListView android:id="@+id/LV_Device"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/btn_top10"
        android:layout_above="@id/LV_Device"/>

    <Button android:id="@+id/btn_clearResult"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Clear Results"
        android:layout_below="@id/LV_Device"/>  

</RelativeLayout>

This will give a result like this

enter image description here

If i add some values to the ListView then its ok, the button below will be show

enter image description here

But if the listview becomes larger than the screen size then the button below that will not be visible even after scrolling to the bottom of the listView

enter image description here

How to solve this issue?? I don't want button to be fixed at the bottom of the screen. I want the button to be show at the end of the ListView only

like image 726
Shijilal Avatar asked Feb 14 '11 03:02

Shijilal


1 Answers

Change your ListView's height to 0dip. Then change the attribute

android:layout_above="@id/LV_Device" 

to

 android:layout_above="@+id/btn_clearResult"

Finally, modify the last button by removing android:layout_below and add instead android:layout_alignParentBottom="true".

like image 123
Romain Guy Avatar answered Oct 19 '22 18:10

Romain Guy