baoyongzhang / android-PullRefreshLayout

This component like SwipeRefreshLayout, it is more beautiful than SwipeRefreshLayout.
MIT License
2.07k stars 517 forks source link

Scroll problem when having a ScrollView in the PullRefreshLayout #11

Closed hyukchan closed 9 years ago

hyukchan commented 9 years ago

Hi, I'm encountering a problem when I have a ScrollView inside your PullRefreshLayout. When I scroll to the end of the ScrollView and I want to scroll back to the top, the scroll is on PullRefreshLayout and not on the ScrollView. So I can't scroll back when I go to the end of the ScrollView !

I'm not sure if it's very clear :/

liaohuqiu commented 9 years ago

Maybe there is a little flaw in the method checkCanScroolDown.

seah0rses commented 9 years ago

fixed this by passing the child directly.

made this small method inside pullrefreshlayout.java:

View deChild;

public void setDeChild(View deChild){
    this.deChild=deChild;
}

Then inside onInterceptTouchEvent make this small adjustment:

public boolean onInterceptTouchEvent(MotionEvent ev) {

    boolean deFlag = false;

    if(deChild!=null) {
        deFlag = ViewCompat.canScrollVertically(deChild, -1);
    }

    if (!isEnabled() || canChildScrollUp() || deFlag || mRefreshing) {
        return false;
    }
    ....

Inside your main activity, call setDeChild after you initialize your pullrefresh layout..

    final PullRefreshLayout layout = (PullRefreshLayout) findViewById(R.id.swipeRefreshLayout);
    layout.setDeChild(listView);
d7coders commented 9 years ago

Thanks :) :+1: , after make this changes it's work now

hyukchan commented 9 years ago

Ok thanks for your solution :+1:

sujewan commented 8 years ago

Thanks for your solution

joshharington commented 7 years ago

@seah0rses This works. Thank you so much!