當元素的大小很少時,如列表視圖中的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>
這是怪異的地獄。我不知道,這一切看起來不錯。嘗試'ListView':'android:layout_gravity =「top」'。我不知道這是否會有所幫助,但是誰知道? – AedonEtLIRA
不起作用... – user818117