MaterialViewPager icon indicating copy to clipboard operation
MaterialViewPager copied to clipboard

Can't scroll down if the first tab is not scrollable and the second is.

Open jkwiecien opened this issue 9 years ago • 20 comments

I know the title is confusing so I recorded this:

Initial tab "Rozmiar" is not scrollable as the content is really small. I switch to another "Galeria" and here I scroll down so the header is hidden. When I get back to "Rozmiar" I see header field but it's content is still somewhere over the screen :)

jkwiecien avatar Jun 25 '15 12:06 jkwiecien

Im having a similar problem with expandings/collapsing lists making the material view pager unreachable. Can we get a method to expand the material view pager to a certain height?

Mark-William-Schumacher avatar Jun 25 '15 17:06 Mark-William-Schumacher

Yea i have the same problem ..This is right now the main problem in my app :/ if there is a fix id love to know how to

Curwer-zz avatar Jun 25 '15 20:06 Curwer-zz

Yes I know why, it's because the ScrollView or the Recyclerview on your second page (ROZAR) is to small to scroll... Can you try to add an empty view behind your cards, like 1000dp and tell me if the bug already happen please ? (it's a small fix, not a good solution)

2015-06-25 22:26 GMT+02:00 Niclas [email protected]:

Yea i have the same problem ..This is right now the main problem in my app :/ if there is a fix id love to know how to

— Reply to this email directly or view it on GitHub https://github.com/florent37/MaterialViewPager/issues/89#issuecomment-115387044 .

florent37 avatar Jun 25 '15 20:06 florent37

i found out something, its not the best fix .. but i guess it will do for now. In your fragment where you have your recyclerview:

@Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (isVisibleToUser) {
            mResetRecycler.smoothScrollToPosition(0); //I use this to get back to pos 0 if i have many cards
            MaterialViewPagerHelper.getAnimator(getActivity()).onMaterialScrolled(null, 0); //jump back to 0 Yoffset
        }
    }

What this does is that it will tell your fragment that its right not being shown for the user. (This will not provide any animation it will just end up at the start position again.

I just this to register the RecyclerView in my onCreateView

MaterialViewPagerHelper.registerRecyclerView(getActivity(), mResetRecycler, null);

Curwer-zz avatar Jun 25 '15 21:06 Curwer-zz

but yea, its not the sexiest solution but it works, would be great if could create a

MaterialViewPagerHelper.getAnimator(getActivity()).onMaterialScrolled(null, 0).animate(true);

To animate the view back to its normal position or to what ever Yoffset the user chose

Curwer-zz avatar Jun 25 '15 21:06 Curwer-zz

@florent37 yea i tried that, or i tried adding 3 more items to the adapter but with setVisa(INVISIBLE); on everything position > 0, but this gave me inviible scrollable items lol and yes while that added the scroll to the view, it didnt pop back as i wanted. So thats when i did found the solution above. This will every time you come to this fragment the adapter will take you to position 0, then set the view after scroll was done, with the onMaterialScrolled(). But now i only have 1 card, so no more weird invisible scrolling on items.

Curwer-zz avatar Jun 25 '15 21:06 Curwer-zz

+1 for MaterialViewPagerHelper.getAnimator(getActivity()).onMaterialScrolled(null, 0).animate(true);

Placing empty view in the small tab is not an option because it's an empty view and the user would have to scroll manually anyway ;)

jkwiecien avatar Jun 26 '15 07:06 jkwiecien

yes, the

@Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (isVisibleToUser) {
            mResetRecycler.smoothScrollToPosition(0); //I use this to get back to pos 0 if i have many cards
            MaterialViewPagerHelper.getAnimator(getActivity()).onMaterialScrolled(null, 0); //jump back to 0 Yoffset
        }
    }

seems correct, it force to scroll top

florent37 avatar Jun 26 '15 07:06 florent37

I have an idea, it could be directly implemented into MaterialViewPager, if the scroll content is too small, or can't scroll, when it becomes visible again, we scrool to top with this code. Do you agree ?

florent37 avatar Jun 26 '15 07:06 florent37

yea, that sounds good :)

Curwer-zz avatar Jun 26 '15 07:06 Curwer-zz

Hope my small "fix" will help anyone with this problem until we have a official fix :)

Curwer-zz avatar Jun 26 '15 08:06 Curwer-zz

When will 1.0.6 roll out?

jkwiecien avatar Jul 07 '15 06:07 jkwiecien

@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
    super.setUserVisibleHint(isVisibleToUser);
    if (isVisibleToUser) {
        mResetRecycler.smoothScrollToPosition(0); //I use this to get back to pos 0 if i have many cards
        MaterialViewPagerHelper.getAnimator(getActivity()).onMaterialScrolled(null, 0); //jump back to 0 Yoffset
    }
}

is a fragment method, I don't know how to implement it for the users

what would be the best solutions ?

florent37 avatar Jul 07 '15 08:07 florent37

Maybe, if the user swipes to to the next page (left or right swipe). And lets say that the user has scrolled up a bit on ythe current view so that toolbar and icon has been collapsed. When the user swipes, at the same x-velocity the toolbar expands again. So on swipe, you trigger the scroll and convert the x-velocity in the swipe to a y-velocity in the scroll of the recycler or listview?

The programmer can add this by calling in the xml app:expande_on_swipe=true" or by code MaterialViewPagerHelper.smothScrollViewToOnSwipe(Recyclerview, ListView, y-offset)

Curwer-zz avatar Jul 07 '15 10:07 Curwer-zz

I worked for you this morning guys :)

can you try with the 1.0.5.3 ? (i'll send the 1.0.6 if this version is ok)

florent37 avatar Jul 07 '15 10:07 florent37

So how are we supposed to handle this in 1.0.5.3?

Btw I just noticed that when I scrolled up my list a bit, so the tabs got pushed up a bit I couldn't click on them anymore (swiping still works though)

jkwiecien avatar Jul 07 '15 13:07 jkwiecien

Hey, what's the status on this?

jkwiecien avatar Jul 23 '15 19:07 jkwiecien

Hi,

I'm also unclear on how to implement the improvement you made on this issue. Could you clarify this for us please?

Thank you

ghost avatar May 27 '16 21:05 ghost

MaterialViewPagerHelper.getAnimator(getActivity()).onMaterialScrolled(null, 0); does not seem to work as it is private. So was this issue resolved? or is there a way to programmatically show the header?

shahimclt avatar Jun 16 '17 10:06 shahimclt

Hello, I am trying to use : MaterialViewPagerHelper.getAnimator(getActivity()).onMaterialScrolled(null, 0); but is it private so it doesn't work ... Can you please help me?

ImNeos avatar Apr 23 '19 16:04 ImNeos