且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

创建一个具有水平和垂直滚动的 RecyclerView

更新时间:2022-05-17 10:23:02

我对应用程序所出现的所有问题感到非常生气,而这些问题没有考虑过最简单的解决方案.

I was so angry about all the problems that had tended with the application that had not thought about the easiest solution.

在一个 RecyclerView 中由两个 XML 文件组成,主要的一个是声明 RecyclerView 的文件,另一个包含内容.

In a RecyclerView consists of two XML files, the main one where the RecyclerView is declared and another with content.

最简单的解决方案是在 ScrollView 中引入 RecyclerView.由于 ScrollView,我可以一次移动所有项目 由于 RecyclerView 在横向模式下,我可以移动项目.

The simplest solution was to introduce the RecyclerView within a ScrollView. So I can move all items at a time thanks to ScrollView vertically and horizontally I can move the items thanks to RecyclerView in landscape mode.

activity_main.xml

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="@dimen/cardIn_margin_ext">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scrollbarStyle="outsideInset"
            android:scrollbars="horizontal" />

</ScrollView>