noties / Scrollable

Android scrollable tabs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dude

xellDart opened this issue · comments

Sorry for the noob question, i have activity with tabs, in have 3 tabs(3 fragments), i the first two i have recycler view, i need to set this {canscroll vertical}, i follow your sample, but this not work...

In fragments that i have recycler view, i implements CanScrollVerticallyDelegate, OnFlingOverListener methods:

override fun canScrollVertically(direction: Int): Boolean {
return recycler_view_relation.canScrollVertically(direction)
}

override fun onFlingOver(y: Int, duration: Long) {
        recycler_view_relation.smoothScrollBy(0, y)
} 

On activity i have: (nts top is my tabs)
scrollable_layout.setDraggableView(nts_top)

is correct?
And how to collpse on click

Hey dude!

The main idea when dealing with ViewPager and Fragments is that you need to delegate callbacks from currently visible fragment. ViewPager doesn't provide such functionality (to obtain currently selected Fragment), so I have created an utility class for this: https://github.com/noties/Scrollable/blob/master/sample/src/main/java/ru/noties/scrollable/sample/pager/fragment/FragmentPagerActivity.java#L148

In short: it searches fragment by tag ( https://github.com/noties/Scrollable/blob/master/sample/src/main/java/ru/noties/scrollable/sample/pager/fragment/FragmentPagerActivity.java#L183 ). The bad thing is: it relies on internal functionality of FragmentPagerAdapter (from support v4) by constructing the tag manually. So, if later releases of v4 have changed how tag is constructed, this method won't work. The good solution would be creating own FragmentPagerAdapter and exposing a way to obtain tag of attached Fragment.

Most likely it is the issue, but if you could show me your code, I would be able to tell more.

About collapsing: what clicks would you like to track? Anyway to collapse you do something like this:

final ValueAnimator animator = scrollableLayout.animateScroll(scrollableLayout.getMaxScrollY());
animator.setDuration(250L);
// other configuration like Interpolator, etc
animator.start();

okay, then