2011-08-25 51 views
1

當元素的大小很少時,如列表視圖中的1,2或3 它顯示底部的元素。如何顯示頂部的元素,即使有幾個元素?這是一個screenshot當有少量元素時,Android listview在底部顯示元素?

這裏是我的XML代碼:

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

    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:padding="4px" 
     android:paddingBottom="4px" 
     android:background="@drawable/fbbar" 
     android:layout_height="50dip"> 
    <EditText android:id="@+id/searchText" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:layout_gravity="bottom" 
     android:hint="type to search..." 
     android:drawableRight="@drawable/ic_search_text"/> 
    <Button android:id="@+id/btn_contacts_refresh" 
     android:layout_width="0px" 
     android:layout_height="0px" 
     android:drawableTop="@drawable/refresh"/> 
    </LinearLayout> 

    <ListView android:id="@+id/contactsList" 
     android:layout_width="match_parent" 
     android:layout_height="fill_parent" 
     android:transcriptMode="alwaysScroll" 
     android:background="#fff" 
     android:cacheColorHint="#00000000" 
     android:dividerHeight="1px" android:divider="#777a"/> 

    <LinearLayout 
     android:layout_height="2dip" 
     android:layout_width="match_parent" 
     android:orientation="horizontal" 
     android:background="@drawable/fbbar"> 
    </LinearLayout> 
</LinearLayout> 
+0

這是怪異的地獄。我不知道,這一切看起來不錯。嘗試'ListView':'android:layout_gravity =「top」'。我不知道這是否會有所幫助,但是誰知道? – AedonEtLIRA

+0

不起作用... – user818117

回答

0

我覺得你的問題是這裏的android:transcriptMode = 「alwaysScroll」

+0

它不起作用 – user818117

+0

其實我發現這個bug是在java方面對不起 – user818117

+0

你能解釋一下錯誤嗎?我很感興趣,因爲我遇到了同樣的情況。 – Neonamu