我正在开发一个 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混在一起的。