L4Digital / FastScroll

A ListView-like FastScroller for Android’s RecyclerView.
Apache License 2.0
901 stars 75 forks source link

Sup! Using FastScrollRecyclerView inside ScrollView doesn't work, should be? #1

Closed iRYO400 closed 7 years ago

iRYO400 commented 7 years ago

Hi! Library is cool and smooth to use. Like it. I'm interesting. Is this possible to make it working inside ScrollView/NestedSV? I tried. but it doesn't work. The XML

<ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">
                    <com.l4digital.fastscroll.FastScrollRecyclerView
                        android:id="@+id/recycler_view"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        app:bubbleColor="@color/blue_main"
                        app:bubbleTextColor="#ffffff"
                        app:handleColor="#999999"
                        app:hideScrollbar="false"
                        app:showTrack="true"
                        app:trackColor="@color/blue_light" />
</ScrollView>

In code

                    binding.recyclerView.setAdapter(adapter);
                    binding.recyclerView.setNestedScrollingEnabled(true); // with false the same result
                    binding.recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

Thanks!

randr0id commented 7 years ago

Your parent ViewGroup is a ScrollView which is unnecessary since RecyclerView provides scrolling. Try replacing it with a FrameLayout.

Currently the parent ViewGroup must be a FrameLayout or RelativeLayout in order for the FastScroller to be properly displayed on top of the RecyclerView. We plan to add support for CoordinatorLayout and ConstraintLayout in the future.

iRYO400 commented 7 years ago

ok. but I got the same if I do next

<ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">
                    <com.l4digital.fastscroll.FastScrollRecyclerView
                        android:id="@+id/recycler_view"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        app:bubbleColor="@color/blue_main"
                        app:bubbleTextColor="#ffffff"
                        app:handleColor="#999999"
                        app:hideScrollbar="false"
                        app:showTrack="true"
                        app:trackColor="@color/blue_light" />
              </FrameLayout>
</ScrollView>
randr0id commented 7 years ago

What is the error you are seeing? You might need to use NestedScrollView instead of ScrollView.

iRYO400 commented 7 years ago

It's not an error. I just cant scroll it. The same if I use NestedScrollView Please look at gif ezgif-4081226412

iRYO400 commented 7 years ago

And I also tried with RecyclerView.setNestedScroll(false)

zdunaisky-chwy commented 7 years ago

@iRYO400 - The layout shown in your GIF should not need a ScrollView at all. Have you tried removing any parent scrollview so your XML looks like:

<FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.l4digital.fastscroll.FastScrollRecyclerView
                android:id="@+id/recycler_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:bubbleColor="@color/blue_main"
                app:bubbleTextColor="#ffffff"
                app:handleColor="#999999"
                app:hideScrollbar="false"
                app:showTrack="true"
                app:trackColor="@color/blue_light" />
</FrameLayout>
iRYO400 commented 7 years ago

@zacharyyy hi! The gif shows a sample layout. I didn't show that I have another RecyclerView(for friend invites) above FastScrollRecyclerView(list of current friends). Today I've done with the final layout:

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <include
                android:id="@+id/toolbar"
                layout="@layout/toolbar_stavki"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="56dp">

                <android.support.v7.widget.SearchView
                    android:id="@+id/search_view"
                    android:layout_width="match_parent"
                    android:layout_height="32dp"
                    android:layout_gravity="center"
                    android:layout_marginBottom="16dp"
                    android:layout_marginLeft="12dp"
                    android:layout_marginRight="12dp"
                    android:layout_marginTop="16dp"
                    android:background="@drawable/searchview_round_bg"
                    android:gravity="center"
                    android:queryHint="Search" />
            </FrameLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/recyclerview_fragment2"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />
            </LinearLayout>

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <com.l4digital.fastscroll.FastScrollRecyclerView
                    android:id="@+id/recycler_view"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    app:bubbleColor="@color/blue_main"
                    app:bubbleTextColor="#ffffff"
                    app:handleColor="#999999"
                    app:hideScrollbar="false"
                    app:showTrack="true"
                    app:trackColor="@color/blue_light" />
            </FrameLayout>
        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>

Code:

                    adapter = new FriendsAdapter(friendsChildModelList);
                    binding.recyclerView.setAdapter(adapter);
                    binding.recyclerView.setNestedScrollingEnabled(true);
                    binding.recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

                    adapter2 = new FriendsInvitesAdapter(invitesChildModelList);
                    binding.recyclerviewFragment2.setAdapter(adapter2);
                    binding.recyclerviewFragment2.setNestedScrollingEnabled(true);
                    binding.recyclerviewFragment2.setLayoutManager(new inearLayoutManager(getActivity()));

Can you please give any idea how to handle that?

zdunaisky-chwy commented 7 years ago

There are a couple things that stand out as possible issues.

  1. You have two RecyclerViews in the same layout with layout_height=match_parent. Are they both vertically scrolling?
  2. Your layout manager don't specify VERTICAL or HORIZONTAL. Should look something like:
binding.recyclerviewFragment2.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL/HORIZONTAL, false));

If both of your recyclerviews use VERTICAL orientation then your layout will likely have issues of the views squashing each other. You should only need one vertically scrolling recyclerview with heterogenous layouts.