Missing button placed after ListView

I have a layout with 3 buttons at the top, and then a ListView, and then a button below the list. 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 produce a result similar to this.

enter image description here

If I add some values ​​to the ListView, then it will be fine, the button below will be shown

enter image description here

But if the list is larger than the screen size, then the button below this will not be visible even after scrolling at the bottom of the list

enter image description here

How to solve this problem? I do not want the button to be fixed at the bottom of the screen. I want the button to appear only at the end of the ListView

+6
android android-layout listview
source share
5 answers

Change the height of the ListView to 0dip . Then change the attribute

 android:layout_above="@id/LV_Device" 

to

  android:layout_above="@+id/btn_clearResult" 

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

+5
source share

If you have an answer, this is for those who are still looking for the answer to your question. You should use ListView.addFooterView(yourbutton) in your list. (but do not forget to put this expression before installing the adapter for your list, as indicated in the document.)

+5
source share

Shijilal you can try this is your top button is the button of your bottom group

0
source share

put your RelativeLayout in the scroll so that your button will display even after using the scroll, this may work

 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ScrollView01" android:layout_width="fill_parent" android:paddingTop="10dip" android:layout_height="fill_parent" android:paddingBottom="10dip"> <RelativeLayout 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> 

0
source share

Do not initialize the item in the listView.so list item at the top. After you add a button, the item clear decreases. But when more items are added, the clear button disappears and goes off the screen. I want to know that Initialy, when elements are added, clears the button. when a clear button is reached from below, then it does not go down further. You can add more items to the list.

0
source share

All Articles