Create a RecyclerView with horizontal and vertical scrolling

Over the past few weeks, I have learned to use RecyclerView . I need to implement a horizontal list, i.e. By turning the device in landscape mode as follows:

enter image description here

I found a better solution for this (how to create a horizontal offset RecyclerView , here ), but ran into another problem. The RecyclerView element was greater than the height of the device (horizontal, horizontal), so I need to create a vertical and horizontal offset at the same time.

I reviewed the Android Developer methods for the LayoutManager class, but my skills are not high enough to understand most methods. I also tried placing the RecyclerView vertically inside another RecyclerView horizontally with all the content, but I get an error:

IllegalStateException: RecyclerView does not have LayoutManager

To survive this, I deleted all the <View ... /> elements from the XML file, but this does not produce any results.

To clarify what I'm asking: is it possible for my layout to scroll both horizontally and vertically, and if you could explain how I would appreciate it.

+17
android android-layout android-studio scroll android-recyclerview
source share
1 answer

I was so angry at all the problems that related to the application, which did not think about the simplest solution.

The RecyclerView consists of two XML files, the main one where the RecyclerView is declared, and the other with the content.

The simplest solution was to introduce a RecyclerView within the ScrollView . That way, I can move all objects at a time, thanks to ScrollView vertically and horizontally. I can move elements 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> 
+17
source share

All Articles