2012-05-13 29 views
1

現在我有這樣的佈局:Android - 我如何讓整個頁面滾動,如果我有一個listView裏面?

<?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> 

但它顯示了一個破碎的佈局。

我想要做的是用ListView加載項目列表,然後在其下添加一個按鈕。

我怎麼能做到這一點?

謝謝!

回答

3

你不能嵌套視圖可以在相同的方向滾動,沒有奇怪的東西發生。但是,您可以將標題和頁腳視圖添加到列表視圖,這應該會產生相同的效果。

+0

頁腳的想法很有意思,但我想添加一些特定於此頁面的內容。有沒有辦法改變這種佈局,以便它只顯示列表下面的最後一個按鈕? – GeekedOut

+0

我不確定你的意思。頁腳僅適用於您設置的列表視圖。也許如果你做了一個顯示你想滾動的圖表,這可能會有所幫助。一般來說,如果您希望在頂部/底部的滾動列表中顯示某些內容,頁腳就是要走的路。 – Jords

相關問題