GeekedOut
GeekedOut

Reputation: 17185

Android - How can I make the whole page scroll if I have a listView inside?

Right now I have this layout:

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

<ScrollView
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" >    

<LinearLayout 
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >        
<TextView
    android:id="@+id/view_name"    
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Business:"
    />         

<!--  
<TextView
    android:id="@+id/problem_name"    
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Loading..."
    />
    -->       

<TextView
    android:id="@+id/business_privacy"    
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Loading..."
    />    

    <Button
    android:id="@+id/learn"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop ="5dp"
    android:text="Learn About Business Topics Below"
    android:textColor="@color/light_best_blue"
    />    



    <ListView
    android:id="@android:id/list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@+id/label"
        android:textSize="20px" >        


    </ListView>

    <Button
    android:id="@+id/extra_help"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop ="5dp"
    android:text="If You Need Help Planning"
    android:textColor="@color/light_best_blue"
    />             

</LinearLayout>

</ScrollView>

</LinearLayout>

But it shows a broken layout.

What I was trying to do is load the list of items with the ListView, and then add a button underneath that.

How could I accomplish that?

Thanks!

Upvotes: 1

Views: 808

Answers (1)

Jords
Jords

Reputation: 1875

You can't nest views which are scrollable in the same direction without weird stuff happening. However, you can add header and footer views to the listview, which should give the same effect.

Upvotes: 3

Related Questions