簡體   English   中英

Android - 如果我在里面有一個listView,如何讓整個頁面滾動?

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

現在我有這個布局:

<?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加載項目列表,然后在其下面添加一個按鈕。

我怎么能做到這一點?

謝謝!

你不能嵌套可以在同一方向滾動的視圖而不會發生奇怪的事情。 但是,您可以向列表視圖添加頁眉和頁腳視圖,這應該會產生相同的效果。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM