2010-12-03 56 views
1

我有以下的XML和我沒有做任何幻想與壓倒一切的滾動行爲:滾動型不響應

<?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:id="@+id/myscrollview" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:fillViewport="true" 
     android:layout_weight="1"> 
      <ListView 
       android:id="@+id/mylistview" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" /> 
    </ScrollView> 
    <TextView 
     android:id="@+id/my_empty" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:text="@string/my_foo" 
     android:gravity="center" 
     android:visibility="gone" 
    /> 
</LinearLayout> 

然而,當嵌入列表視圖並以壓力機和長按響應,它不會滾動。我究竟做錯了什麼?

尾隨的TextView是listview的emptyview。

+1

你們都是我眼中的贏家。 – SapphireSun 2010-12-03 05:25:11

回答

4

滾動型不與任何其他的觀點很好地發揮這一卷軸本身,即WebView中,ListView控件等

嘗試相對佈局看如果這樣做你需要什麼。

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

<ListView 
    android:id="@+id/mylistview" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_alingParentTop="true" 
/> 
<TextView 
    android:id="@+id/my_empty" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/my_foo" 
    android:gravity="center" 
    android:visibility="gone" 
    android:layout_alignParentBottom="true" 
/> 
</RelativeLayout> 
2

在Android中,它不應該把ListView放在ScrollView中。不起作用。

2

將ListView移出ScrollView。它導致的問題,而且是不必要的(ListView的滾動處理自身。)