Documente Academic
Documente Profesional
Documente Cultură
I have a ListView with 2 footer views. The first one is a bunch of TextView s, while the second one is a button. I'm trying to fix the second footer
so that it always shows at the bottom of the screen.
1. alignParentBottom = true
2. layout_gravity="bottom"
3. footerView2.bringToFront()
And combinations of the above. But none of them worked out. How can I achieve this?
UPDATE
I shouldn't have added the View which I always want on the screen (fixed) as footer.
I just added the wannabe-fixed-view with the listView. Did alignParentBottom = true and also view.bringToFront() . It worked out for me.
This second footer will be visible and fixed when whole of the listview will be scrolled , right ? Prateek Mar
7 '16 at 7:24
Yeah, when the whole listview is scrolled, the first footer is scrolled... The second footer will always be
visible and fixed at the bottom. Akeshwar Jha Mar 7 '16 at 7:25
1 Don't use a footer if you want it to have a permanent, fixed location. Add another View below your
ListView as part of your layout file. PPartisan Mar 7 '16 at 7:27
1 @user5038993 was about to right the same as PPasrtisan. Prateek Mar 7 '16 at 7:28
3 Answers
<Button
android:id="@+id/btn_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Bottom button"/>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/btn_bottom"/>
</RelativeLayout>
https://stackoverflow.com/questions/35838225/how-to-make-the-last-footer-fixed-listview 1/2
9/24/2017 android - How to make the last footer fixed (ListView) - Stack Overflow
yup, that was what I was missing. Clear point. I also had to use bringToFront . Akeshwar Jha Mar 7 '16
at 7:34
Create separate xml file which contain all textviews and button you want as footer part.Then
bind this xml as a footer of listview. You can binf footer with listview by this method:
listview.addFooterView(footerView);
For example:
lvAddress.addFooterView(footerView);
If you are Trying to add a View which will be shown even if we scroll the List Up or
Down... u can do something like this. I had done this before But as a header.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:id="@+id/new_container"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="LOAD EARLIER MESSAGES"
android:id="@+id/loadMore"
android:background="#90F58220"
android:visibility="visible"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/listContainer"
android:layout_below="@+id/loadMore"
android:layout_above="@+id/container">
<ListView
android:id="@+id/messagesContainer"
android:transcriptMode="normal"
android:dividerHeight="0dp"
android:divider="@null"
android:stackFromBottom="true"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/container"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:background="#ffffff"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:layout_height="wrap_content" >
</RelativeLayout>
android:layout_below="@+id/loadMore"
android:layout_above="@+id/container"
to
android:layout_above="@+id/loadMore"
https://stackoverflow.com/questions/35838225/how-to-make-the-last-footer-fixed-listview 2/2