項目中遇見這個問題很蛋疼,有時候在4.4沒問題,但是在7.0有問題。
也就是說有些版本會出現,有些不會。
網上的解決辦法無非就是這幾種:
1.recyclerview 高度設置為:wrap_content
2.item的高度為;wrap_content
3.NestedScrollView添加屬性 android:fillViewport="true"
等等。。。
試了許多次,結果都懷疑人生了。
其實很簡單,recyclerview的高度可以設置為match, 但是需要加個margin_bottom="40dp"
你會發現,神奇的事情發生了。
<android.support.v7.widget.RecyclerView
? ? ? ? ? ? ? ? android:id="@+id/recyclerView"
? ? ? ? ? ? ? ? android:layout_width="match_parent"
? ? ? ? ? ? ? ? android:layout_height="match_parent"
? ? ? ? ? ? ? ? android:layout_marginBottom="40dp"
? ? ? ? ? ? ? ? ?/>
有時間再去整理一下原因。寫這個是想讓大家搞不定的可以多一種嘗試!