RecyclerView: Implement Vertical and Horizontal scrolling tables. Multiple tables one below the other
<p>I have to work on a requirement where I have to show 3 scrolling tables one below the other. Tables will have multiple Rows and columns. It will overflow the screen both horizontally and vertically.
<a href="https://i.stack.imgur.com/pr7m0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pr7m0.jpg" alt="Image to show what i am trying to achieve"></a></p>

<p>I have written a sample project. But it is not according to what I need. 
In current code, each rows scroll individually. I need to divide them in Tables and make them scroll all at once as shown in the diagram.
Will post the code below.</p>

<p>horizontal_item.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="wrap_content"
      android:layout_height="wrap_content"&gt;

&lt;TextView
    android:id="@+id/horizontal_item_text"
    android:textColor="@android:color/black"
    android:layout_width="100dp"
    android:layout_margin="5dp"
    android:background="@drawable/bg_white_blue_stroke"
    android:padding="5dp"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="dsfdsfsdf"/&gt;

 &lt;/LinearLayout&gt;
</code></pre>

<p>HorizontalRowAdapter.java</p>

<pre><code>public class HorizontalRowAdapter extends RecyclerView.Adapter&lt;RecyclerView.ViewHolder&gt; {

private List&lt;String&gt; mDataList;
private int mRowIndex = -1;

public HorizontalRowAdapter() {
}

public void setData(List&lt;String&gt; data) {
    if (mDataList != data) {
        mDataList = data;
        notifyDataSetChanged();
    }
}

public void setRowIndex(int index) {
    mRowIndex = index;
}

private class ItemViewHolder extends RecyclerView.ViewHolder {

    private TextView text;

    public ItemViewHolder(View itemView) {
        super(itemView);
        text = (TextView) itemView.findViewById(R.id.horizontal_item_text);
    }
}

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    Context context = parent.getContext();
    View itemView = LayoutInflater.from(context).inflate(R.layout.horizontal_item, parent, false);
    ItemViewHolder holder = new ItemViewHolder(itemView);
    return holder;
}

@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {

    ItemViewHolder holder = (ItemViewHolder) viewHolder;
    holder.text.setText(mDataList.get(position));
    holder.itemView.setTag(position);
}

@Override
public int getItemCount() {
    return mDataList.size();
}
 }
</code></pre>

<p>vertical_item.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="wrap_content"&gt;

&lt;LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"&gt;

    &lt;TextView
        android:id="@+id/item_name_tv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:textColor="@android:color/holo_blue_bright"/&gt;

    &lt;android.support.v7.widget.RecyclerView
        android:id="@+id/horizontal_list"
        android:layout_width="wrap_content"
        android:layout_marginTop="5dp"
        android:layout_height="wrap_content"
        android:visibility="visible"/&gt;

&lt;/LinearLayout&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<p>VerticalListAdapter.java</p>

<pre><code>public class VerticalListAdapter extends RecyclerView.Adapter&lt;VerticalListAdapter.SimpleViewHolder&gt;{

private final Context mContext;
private static List&lt;SampleData&gt; mData;
private static RecyclerView horizontalList;

@Override
public SimpleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    final View view = LayoutInflater.from(mContext).inflate(R.layout.vertical_item, parent, false);
    return new SimpleViewHolder(view);
}

@Override
public void onBindViewHolder(SimpleViewHolder holder, int position) {
    holder.title.setText(mData.get(position).getTitle());
    holder.horizontalAdapter.setData(mData.get(position).getTags()); // List of Strings
    holder.horizontalAdapter.setRowIndex(position);
}

// Insert a new item to the RecyclerView on a predefined position
public void insert(int position, SampleData data) {
    mData.add(position, data);
    notifyItemInserted(position);
}

@Override
public int getItemCount() {
    return mData.size();
}

public static class SimpleViewHolder extends RecyclerView.ViewHolder {
    public final TextView title;
    private HorizontalRowAdapter horizontalAdapter;

    public SimpleViewHolder(View view) {
        super(view);
        Context context = itemView.getContext();
        title = (TextView) view.findViewById(R.id.item_name_tv);
        horizontalList = (RecyclerView) itemView.findViewById(R.id.horizontal_list);
        horizontalList.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
        horizontalAdapter = new HorizontalRowAdapter();
        horizontalList.setAdapter(horizontalAdapter);
    }
}

public VerticalListAdapter(Context mContext, List&lt;SampleData&gt; mData) {
    this.mContext = mContext;
    this.mData = mData;
}
}
</code></pre>

<p>MainActivity.java</p>

<pre><code>public class MainActivity extends Activity {


RecyclerView vertical_list;
VerticalListAdapter verticalListAdapter;
List&lt;SampleData&gt; mData;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    vertical_list = (RecyclerView) findViewById(R.id.vertical_list);
    vertical_list.setHasFixedSize(true);
    LinearLayoutManager llm = new LinearLayoutManager(this);
    vertical_list.setLayoutManager(llm);
    prepareData();
    verticalListAdapter = new VerticalListAdapter(this,mData);
    vertical_list.setAdapter(verticalListAdapter);


}

private void prepareData(){
    mData = new ArrayList&lt;&gt;();
    for(int i = 0; i &lt; 20; i ++){
        SampleData sampleData = new SampleData();
        sampleData.setTitle("Position = "+i);

        List&lt;String&gt; tags = new ArrayList&lt;&gt;();
        for(int j = 0; j &lt;= i; j ++){
            tags.add("Inner Position = "+j);
        }
        sampleData.setTags(tags);

        mData.add(sampleData);

    }
}


}
</code></pre>

<p>Any help or advice is appreciated. 
Thank you</p>