1

I am trying to implement horizontal and vertical scrolling for a Recycler view at the same time.I have to show a table of 8 columns, so I plan to implement horizontal and vertical scrolling at the same time.

I tried HorizontalScrollView but it is scrolling horizontally in one row.

list_row.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:clickable="true"
android:background="?android:attr/selectableItemBackground"
android:orientation="vertical">

<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
  >
    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >
    <TextView
    android:id="@+id/title"
    android:textColor="@color/title"
    android:textSize="16dp"
    android:textStyle="bold"
    android:layout_alignParentTop="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
   android:text="aaa"/>

<TextView
    android:id="@+id/genre"
    android:layout_below="@id/title"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="20dp"
    android:text="bbb"/>

<TextView
    android:id="@+id/year"
    android:textColor="@color/year"
    android:layout_width="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_height="wrap_content"
    android:layout_marginLeft="20dp"
    android:text="ccc"/>
    </LinearLayout>
</HorizontalScrollView>
</RelativeLayout>

is there any way to scroll the list horizontally and vertically by the entire table in the same layout.

Binil Surendran
  • 2,374
  • 5
  • 32
  • 56

2 Answers2

0

You can achieve it by using code like:

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

Read already answered question at:

  1. Android -- How to allow horizontal and vertical scrolling
  2. Scrollview vertical and horizontal in android
Community
  • 1
  • 1
ישו אוהב אותך
  • 26,433
  • 11
  • 70
  • 92
0

Put your recyclerView layout to

<android.support.v4.widget.NestedScrollView

it can help you

see this case vertical recyclerView and Horizontal recyclerview scrolling together