reddit / IndicatorFastScroll

Android library providing a simple UI control for scrolling through RecyclerViews
MIT License
707 stars 58 forks source link

Wrong positioned floating thumb? #54

Closed bczhc closed 1 year ago

bczhc commented 2 years ago

I set up my RecyclerView as README writes, but finding the thumb view has a wrong position. Like this:

It's about that I press the letter 'M' (middle of the screen), the thumb starts showing from the top. And then keep sliding the letters on right side, the thumb also follows, starts going down. It always has a half-screen distance between the pressed letter and the thumb.

My XML:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
>
    <androidx.recyclerview.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/recycler_view"
    />
    <com.reddit.indicatorfastscroll.FastScrollerView
            android:layout_width="32dp"
            android:layout_height="match_parent"
            android:id="@+id/fast_scroller"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent"
    />
    <com.reddit.indicatorfastscroll.FastScrollerThumbView
            android:id="@+id/fast_scroller_thumb"
            android:layout_width="40dp"
            android:layout_height="match_parent"
            android:layout_marginEnd="16dp"
            app:layout_constraintBottom_toBottomOf="@+id/fast_scroller"
            app:layout_constraintEnd_toStartOf="@+id/fast_scroller"
            app:layout_constraintTop_toTopOf="@+id/fast_scroller"
    />
</androidx.constraintlayout.widget.ConstraintLayout>
av-shekhawat commented 1 year ago

Recently I have also faced this issue and I solved it by changing the FastScrollerThumbView tag id from fast_scroller_thumb to something else. I don't why but it seems that if you used the same id as the FastScrollerThumbView library layout id i.e. fast_scroller_thumb then it triggers this positioning issue.

bczhc commented 1 year ago

Oh thanks for the info! Now I got it worked!

bczhc commented 1 year ago

I don't know why I picked this conflicted ID for the thumb view... But just having solved it, I can close this issue.