android解決RecyclerView嵌套在NestedScrollView中在解決滑動沖突問題后出現(xiàn)子項顯示不全的問題盈魁。
1.解決滑動沖突的問題在代碼中下入:
recycler.setHasFixedSize(true);
recycler.setNestedScrollingEnabled(false);
但是會出現(xiàn)recyclerview的子項顯示不全的問題翔怎,這時候只需要在布局中:
<android.support.v4.widget.NestedScrollView
? ? android:layout_width="match_parent"
? ? android:layout_height="match_parent"
? ? android:fillViewport="true">
<RelativeLayout
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="match_parent"
? ? ? ? android:descendantFocusability="blocksDescendants">
<android.support.v7.widget.RecyclerView
? ? ? ? ? ? android:id="@+id/rv_data_list"
? ? ? ? ? ? android:layout_width="match_parent"
? ? ? ? ? ? android:layout_height="match_parent"
? ? ? ? ? ? android:overScrollMode="never" />
如上給RecyclerView和NestedScrollView之間給RecyclerView加一層父布局,但是這個父布局只能是RelativeLayout备埃,而不能用比較新的ConstraintLayout姓惑,
然后在RelativeLayout加入?android:descendantFocusability="blocksDescendants"即可。