I have the following layout
Use NestedScrollView with:
app:layout_behavior="@string/appbar_scrolling_view_behavior"
Make your own implementation of SwipeRefreshLayout and override the canChildScrollUp in this way:
@Override
public boolean canChildScrollUp() {
if (scrollView != null)
return scrollView.canScrollVertically(-1);
return false;
}
just replace with any subclass of ScrollView.
If you have layout like this:
<SwipeRefreshLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/your_scroll_view_id">
<LinearLayout>
...
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</SwipeRefreshLayout>
You need to create your own class and override the function in this way:
class SwipeRefreshLayoutCustom extends SwipeRefreshLayout {
public SwipeRefreshLayoutCustom(Context context, AttributeSet attributes) {
super(context, attributes)
}
@override
boolean canChildScrollUp() {
return your_scroll_view_id.scrollY != 0
}
}
I found that if you replace your ScrollView
with a android.support.v4.widget.NestedScrollView
the scrolling behavior will work as you expect it to.