【发布时间】:2019-10-06 22:28:37
【问题描述】:
我在 LinearLayout 中有一个 RecyclerView 布局,该布局也在自定义 NestedScrollView 中。在 api 21 和 22 中,布局看起来应该显示 RecyclerView 的所有元素,但在 api 23 及更高版本中,仅显示一两个项目,而屏幕的其余部分为空白。我知道 RecyclerView 的重点是不使用 wrap_content,但我的理解是你可以。
我注意到,当 RecyclerView 上方的视图可见时,recyclerview 上的 wrap_content 可以正常工作,但在特定情况下,我遇到了问题,这些视图都以编程方式设置为消失,所以它似乎有事可做接着就,随即。所以我不知道该怎么做,因为这些观点应该已经消失了。这是我无法解决的 android sdk 错误吗?
<CustomNestedScrollView
android:id="@+id/editProfileScroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical">
<LinearLayout
android:id="@+id/editProfileMainContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/material_baseline_grid_10x"
android:orientation="vertical">
<!-- More code: TextViews and TextViews inside LinearLayouts -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/editProfileFieldsRV"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</CustomNestedScrollView>
【问题讨论】:
-
尝试使用
RelativeLayout而不是LinearLayout。 -
@HB。那行得通!如果您提交实际答案,我会将其标记为正确。
-
下面回答:)
标签: android android-recyclerview android-linearlayout android-nestedscrollview android-wrap-content