Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scrollview makes bottom views disappear in a Dialog

I have a dialog that has a list (a bunch of TextViews inside a LinearLayout) inside a ScrollView. The layout is as follows:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ProgressBar
        android:id="@+id/delete_progress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="gone" />

    <ScrollView
        android:id="@+id/filename_scroll"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <LinearLayout
            android:id="@+id/filename_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >
        </LinearLayout>
    </ScrollView>

    <View
        android:id="@+id/horisontal_separator"
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:background="@android:color/darker_gray" />

    <LinearLayout
        android:id="@+id/button_container"
        android:layout_width="match_parent"
        android:layout_height="48dp" >

        <Button
            android:id="@+id/load_button"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="@string/button_load"
            android:gravity="center"
            android:layout_weight="1" />

        <View
            android:layout_width="1dp"
            android:layout_height="fill_parent"
            android:background="@android:color/darker_gray" />

        <Button
            android:id="@+id/delete_button"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="@string/button_delete"
            android:gravity="center"
            android:layout_weight="1" />
    </LinearLayout>

</LinearLayout>

It looks like this with only a few items on the list: A few items on the list

But when there's more than can fit on the screen (and there's actual need to scroll), my buttons get pushed below the screen. When scrolling all the way to the bottom, it looks like this: A lot of items on the list

I need the LinearLayout containing the buttons to stay as footer, it shouldn't scroll anywhere and obviously not disappear. I've tried fiddling with the layout heights and weights, but to no avail.

like image 526
j0ntech Avatar asked Apr 24 '13 08:04

j0ntech


People also ask

How many views can you use within a ScrollView?

Only one view can be included in a ScrollView .

What is fillViewport in ScrollView?

fillViewport allows scrollView to extend it's height equals to the full height of device screen's height in the cases when the child of scroll view has less height.

What is the difference between ScrollView and ListView?

ScrollView is used to put different or same child views or layouts and the all can be scrolled. ListView is used to put same child view or layout as multiple items. All these items are also scrollable. Simply ScrollView is for both homogeneous and heterogeneous collection.

Is ScrollView scrollable?

Scroll view supports vertical scrolling only. For horizontal scrolling, use HorizontalScrollView instead. Never add a RecyclerView or ListView to a scroll view. Doing so results in poor user interface performance and a poor user experience.


1 Answers

try to change in scrollView

<ScrollView
    android:id="@+id/filename_scroll"
    android:layout_width="match_parent"
    android:layout_weight="1"
    android:layout_height="0dp" >
like image 92
umesh Avatar answered Sep 29 '22 22:09

umesh