我有兩個問題:
- 如何獲得我的ListView動態高度(FILL_PARENT,match_parent)?如果我寫「layout_height:fill_parent」它不是真的工作
- 我怎樣才能得到一個沒有ScrollView的解決方案,只有ListView? (無滾動型我的滾動條是太遠離正確的網站。)安卓:ListView中不能得到充分的layout_height滾動型
電賀羅賓
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="#e7e7e7">
<TextView
android:id="@+id/date_header"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#bfbfbf"
android:gravity="center"
android:text="05.07.2014"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="@+id/date_header"
android:layout_centerHorizontal="true" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="431dp"
android:divider="@android:color/transparent"
android:dividerHeight="15dp"
android:paddingBottom="20dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingTop="20dp"
android:scrollbars="none" >
</ListView>
</LinearLayout>
</ScrollView>
爲什麼你放在一個滾動型的ListView?這絕對是一個**不好的做法**。 ListView可以自行滾動... –
您也可以避免使用LinearLayout並將ListView的高度設置爲match_parent。 –
沒有必要'ScrollView' –