0

我正在开发一个 Android 应用程序。其中一个屏幕具有这样的 UI: Mockup-UI

这意味着:有许多列,列的宽度也是固定的,所以可能需要水平滚动。每列可能有不同的项目编号,当垂直滚动时,所有列都将滚动。所以我不知道如何实现这个用户界面。我尝试了一个解决方案:在两个滚动视图中创建一些大的回收视图,然后测量它们的所有大小:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fillViewport="true">

            <HorizontalScrollView
                android:id="@+id/horizontalScrollView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fillViewport="true"
                android:scrollbars="none">
                <LinearLayout
                    android:id="@+id/horizontalContainer"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:orientation="horizontal">

                </LinearLayout>
            </HorizontalScrollView>

        </ScrollView>
</LinearLayout>

但是当recyclerview太大时,视图没有被重用,测量所有大小的性能很差。所以我发现一个自定义的布局管理器可以做出这样的recycler view,但是我不知道怎么实现,可能是FixedGridLayoutManager和StaggeredGridLayoutManager混在一起的。

4

2 回答 2

0

您可以尝试https://github.com/lucasr/twoway-view或考虑在此处使用 ViewPager。您可以水平滚动,但一次滚动一个。这不会像列表滚动那样流畅,但如果水平列表不太长,您可以尝试。

于 2016-07-04T09:27:41.447 回答
0

看看这篇关于创建自定义 LayoutManager 的简短但有价值的建议:http: //cases.azoft.com/create-custom-layoutmanager-android/

我建议您还详细了解一些用于在各个方向滚动列表的不同自定义选项的示例。例如,您可以在这里找到 Carousel LayoutManager:https ://github.com/Azoft/CarouselLayoutManager 。

希望这对你有用!

于 2016-07-11T09:41:59.473 回答