android listview 禁止滾動


在一個項目中,使用了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>

     
    


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM