2012-12-20 215 views
2

我的ListView沒有收到onScroll事件,如果它很短並且不填滿整個屏幕,這很奇怪,因爲我已經設置了fill_parent作爲高度。 我的佈局:ListView不滾動

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



<CheckBox 
    android:id="@+id/overview_allcars_checkbox" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:gravity="center" 
    android:text="@string/all_cars" 
    android:textSize="14sp" /> 

<LinearLayout 
    android:id="@+id/list_root" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <ListView 
     android:id="@+id/android:list" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:cacheColorHint="#00000000" 
     android:fadingEdge="horizontal" 
     android:scrollingCache="true" /> 
</LinearLayout> 
</LinearLayout> 
+0

也許你的頂級linearLayout的高度應該是fill_parent,而不是match_parent .. – Daler

+0

我認爲fill_parent和match_parent是等價的。他們的行爲一樣。 – slezadav

回答

0

你會發現這個答案有用: -

Making TextView scrollable on Android

那是什麼讓我有:

<ScrollView 
android:id="@+id/SCROLLER_ID" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:scrollbars="vertical" 
android:fillViewport="true"> 

    <TextView 
    android:id="@+id/TEXT_STATUS_ID" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_weight="1.0"/> 

</ScrollView> 

主要是你換你的TextView的滾動型。

+0

我沒有TextView我有一個ListView,這是一個不錯的主意,把ListView放入一個ScrollView。此外,它不會幫助我觸發ListView上的onScrollListener。 – slezadav

+0

你的回答與問題無關 –