0

How can you have ListView fill the screen and also moving the view below with it until it reaches the bottom? For example, with the image below I would like for the 'Create' button to move down the screen when a new element is add and then when the button reaches the bottom then for the ListView to start Scrolling (with the create button still appearing on screen).

<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:paddingBottom="@dimen/activity_vertical_margin"
        >

    <ListView
            android:id="@+id/galleryList"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="center_vertical"
            android:layout_alignParentTop="true"
            />

    <LinearLayout
            android:id="@+id/lowerButtonLayout"
            android:layout_width="fill_parent"
            android:layout_height="60dp"
            android:background="#ffa8269f"
            android:layout_alignParentBottom="true"
            xmlns:android="http://schemas.android.com/apk/res/android">

        <Button
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@color/button_button_bg_colour"
                android:onClick="addRow"
                android:text="Create"/>
    </LinearLayout>

</RelativeLayout>

enter image description here

Onik
  • 19,396
  • 14
  • 68
  • 91
Mannie
  • 1,608
  • 1
  • 21
  • 33

1 Answers1

0

Unfortunately, it can't be done only with xml file.

The easiest way to go would be to have 2 buttons. One in your main layout and one in your ListView (as a footer view for instance). Then depending on whether the ListView reaches a specific height, just set the visibility of one button to View.GONE. If your cells have the same height, the calculation is pretty straight forward.

Do not use a ListView inside a ScrollView. It will ruin all the purpose of a ListView (being able to recycle cell).

Herve
  • 36
  • 7