在一個項目中,使用了listview和3個include 布局。
結果發現listview為 wrap_content 時,無法撐開布局。但是所有布局並未占滿屏幕。另外,在include中調用軟鍵盤時,listview依然不動,導致編輯內容的位置比較別扭。
反復試驗,總結就是為listview設置高度。但是似乎 listview.setOverScrollMode(View.OVER_SCROLL_NEVER); 不起作用。 布局代碼如下:
(由於 ScrollView 內部只能有一個元素,因此用linearLayout 包括其它元素。)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:orientation="vertical" > <Toolbar android:id="@+id/stb" android:layout_width="match_parent"
android:layout_height="wrap_content" /> <ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:orientation="vertical" android:layout_height="wrap_content"> <ListView android:id="@+id/plv" android:layout_width="match_parent" android:layout_height="230dp" tools:ignore="NestedScrolling" /> <include android:id="@+id/plable" layout="@layout/style_lable" /> <include android:id="@+id/poffset" layout="@layout/price_offset" /> <include android:id="@+id/pedit" layout="@layout/style_edit" /> </LinearLayout> </ScrollView> </LinearLayout>


