2012-05-13 31 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

相关问题