Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to snap every X views? #32

Open
AndroidDeveloperLB opened this issue Nov 7, 2017 · 16 comments
Open

Is it possible to snap every X views? #32

AndroidDeveloperLB opened this issue Nov 7, 2017 · 16 comments
Labels

Comments

@AndroidDeveloperLB
Copy link

For example, suppose I have tens of views to scroll through. If the user scrolled x/2 and a bit more, it will get to the X view.

@rubensousa
Copy link
Owner

This would require another custom SnapHelper. I don't have any plans to implement this, though.

@AndroidDeveloperLB
Copy link
Author

Too bad. Thanks anyway

@rubensousa rubensousa reopened this Aug 30, 2019
@rubensousa rubensousa added this to the 2.2.0 milestone Aug 30, 2019
@rubensousa
Copy link
Owner

rubensousa commented Aug 30, 2019

@rubensousa
Copy link
Owner

rubensousa commented Aug 30, 2019

Check this issue: #29

@rubensousa rubensousa removed this from the 2.2.0 milestone Aug 30, 2019
@AndroidDeveloperLB
Copy link
Author

Why close it if it's not the same?
Can you please post a video of what was added?

@rubensousa
Copy link
Owner

It's not released yet, but it's in the develop branch if you want to check it out.

I closed the issue again since it's not really what you asked for, although it's similar. That's why I linked the other issue.

Here's a preview: https://drive.google.com/file/d/1vbJ5jz39cCcVgWIeGRv5vWF5ESOglDCr/view

@AndroidDeveloperLB
Copy link
Author

It's not the same?
But if it's not the same, why close it?
I'm confused.

@rubensousa
Copy link
Owner

rubensousa commented Aug 31, 2019

I closed it since I don't have plans to work on this specific feature at the moment. You closed this the last time because of that same reason

@AndroidDeveloperLB
Copy link
Author

Sorry I don't remember.
Anyway, you added something that seem what I wrote, no? What's the difference between what I requested and what you've added?

@rubensousa
Copy link
Owner

@AndroidDeveloperLB
Copy link
Author

Oh right.
Sorry for that.
Why not consider adding this functionality ?
It could be nice, for example, for a week view of a calendar app (shows a single week each time)

@rubensousa
Copy link
Owner

Because it requires time I don't have at the moment. However, I could leave this open so that anyone else could work on this instead. Meanwhile, If you need something similar, you could use the other approach.

@AndroidDeveloperLB
Copy link
Author

OK please let it be open, then.

@rubensousa rubensousa reopened this Aug 31, 2019
@albka1986
Copy link

@rubensousa
Hello! Thanks for the lib it's very helpful.
I have a question about the feature "every x" I understand that you provided some another feature, but I try to use it and don't have a profit.
Here is my config:

    val snapHelper = GravitySnapHelper(Gravity.CENTER).apply {
            scrollMsPerInch = 1f
            maxFlingDistance = 20.dp.toPx()
            maxFlingSizeFraction = 0.0001f
        }
        snapHelper.attachToRecyclerView(recyclerView)
        snapHelper.scrollToPosition(Int.MAX_VALUE/2)

My view in XML:

   <com.github.rubensousa.gravitysnaphelper.GravitySnapRecyclerView
            android:id="@+id/camera_type_rv"
            android:layout_width="match_parent"
            android:layout_height="25dp"
            android:layout_marginStart="40dp"
            app:snapMaxFlingSizeFraction="0.1"
            android:layout_marginEnd="40dp"
            app:snapGravity="center"
            android:layout_marginBottom="100dp"
            android:animateLayoutChanges="false"
            android:orientation="horizontal"
            app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            tools:itemCount="3" />

My goal is to go through the list one by one.
But if it's impossible by this lib, I try to set slow speed of scrolling and it doesn't work with method scrollMsPerInch.

This is my current implementation:
https://drive.google.com/file/d/1GuraO_nDQR8IE1jzjZyZ51eyiOzfXlOb/view?usp=sharing

That is what I want to have:
https://drive.google.com/file/d/19k8MFVK69Xiorw1LErUgLt7-wEAQ0fat/view?usp=sharing

@rubensousa
Copy link
Owner

@albka1986 for that use case, you need custom touch event handling. It's not possible to scroll one item only. For that, you need PagerSnapHelper. Check this StackOverflow question: https://stackoverflow.com/questions/53483268/how-to-have-recyclerview-snapped-to-center-and-yet-be-able-to-scroll-to-all-item/53510142#53510142

@albka1986
Copy link

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants