2

What I'd like to do


I've got a RecyclerView with different CardView's inside. For that I wrote a RecycleView.Adapter with a RecyclerView.ViewHolder. Which works perfectly fine.

Now I'd like to have cards which host a ScrollView. My Layout for that looks as follows:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="5dp">

    <TextView
        android:id="@+id/tv_assignment_comments_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="false"
        android:gravity="left"
        android:text="Kommentare"
        android:textSize="@dimen/abc_text_size_large_material" />


    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="250dp"
        android:layout_below="@id/tv_assignment_comments_title"
        android:fillViewport="true">

        <LinearLayout
            android:id="@+id/ll_comments_card_holder"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" />
    </ScrollView>
</RelativeLayout>

So far so good. The Card gets displayed but I can't scroll the content inside the ScrollView only the RecyclerView itself.

How can I make my ScrollView scrollable inside the RecyclerView? Can someone show me the magic?

Tom11
  • 2,419
  • 8
  • 30
  • 56
safari
  • 7,565
  • 18
  • 56
  • 82

1 Answers1

2

I could solve the problem by adding following to my RecyclerView.ViewHolder:

mCommentsHolder.mCommentsScrollContainer.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    v.getParent().requestDisallowInterceptTouchEvent(true);
                    return false;
                }
            });

Now it works perfectly smooth. I've got that from here.

Community
  • 1
  • 1
safari
  • 7,565
  • 18
  • 56
  • 82