Search code examples
androidlistviewandroid-linearlayoutsticky-footer

Sticky Footer Below ListView in Android Layout


I want to put an ad layout at the bottom of a ListView. I want it to stick to the bottom of the page and the listview almost scrolling going behind it.

This is what I have and it doesn't work:

<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:longClickable="true" >
</ListView>

<LinearLayout
    android:id="@+id/adLayout"
    android:layout_width="wrap_content"
    android:layout_height="50dp"
    android:layout_gravity="center_horizontal" >
</LinearLayout>

It is that bottom LinearLayout I need to just stay at bottom. And I want ListView to go all the way to the bottom. Can anyone advise?


Solution

  • Change attributes of your ListView to :

    <ListView
      android:id="@android:id/list"
      android:layout_width="fill_parent"
      android:layout_height="0dp"
      android:layout_weight="1"
      android:longClickable="true" >
    </ListView>
    

    EDIT: Also check that parent layout of your piece of code is LineareLayout with attribute android:orientation="vertical"