水平回收站视图不嵌套

时间:2020-11-12 09:48:22

标签: android xml kotlin android-recyclerview horizontalscrollview

我正在尝试制作一个RecyclerView,它将水平嵌套在HorizontalScrollView中,我希望它将所有项目扩展到其(LinearLayout)中的布局,但是它只显示3个项目,因为由于某种原因未嵌套...

(出于某些奇怪的原因,在我的api 23仿真器中它可以正常工作,但是在更高级别的api上,它不嵌套...)

xml:

            <HorizontalScrollView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="16dp">

                <androidx.core.widget.NestedScrollView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal">

                        <androidx.recyclerview.widget.RecyclerView
                            android:id="@+id/rv_pick_images"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:orientation="horizontal"
                            android:nestedScrollingEnabled="true"
                            app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />

                        <ImageView
                            android:id="@+id/btn_take_pictures"
                            android:layout_width="118dp"
                            android:layout_height="147dp"
                            android:layout_marginTop="8dp"
                            android:layout_marginRight="8dp"
                            android:layout_marginBottom="8dp"
                            android:src="@drawable/dashed_rectangle" />

                    </LinearLayout>

                </androidx.core.widget.NestedScrollView>

            </HorizontalScrollView>

api 23 :(工作正常)

enter image description here

api 29 :(不起作用)

enter image description here

这些图片并没有真正意义,但是在api 23中,当我滚动显示所有图片并且可以无限滚动时,但是在29中它只显示3,因为RecyclerView没有嵌套。 / p>

0 个答案:

没有答案