今天遇到了一个小问题,首页展示列表在被ScrollView嵌套时显示不完整。部分手机显示是正常的,但是较新的手机会出现这个问题。这个问题其实遇见过好多次了,这次特记录下,也方便以后直接来自己的博客来粘贴,哈哈!
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_15"
android:descendantFocusability="blocksDescendants"
app:layout_constraintTop_toBottomOf="@+id/ivPrize">
<android.support.v7.widget.RecyclerView
android:id="@+id/rvHome"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
解决方案就是上边的代码了,核心在于: android:descendantFocusability="blocksDescendants"
在RecyclerView套一层RelativeLayout就是为了让RecyclerView显示完全之前是一直持有焦点的。希望对你也有帮助!