mercredi 13 mai 2015

swiperefreshlayout in an activity that hosts fragments

The short question How do you impliment a SwipeRefreshLayout on an Activity that hosts two Fragments side by side in such a way that the refresh loading spinner apeares centered in the screen.

**The Long question I have an activity that hosts several fragments. I would like to impliment a SwipeRefreshLayout on the activity level to the effect that no matter which fragments are showing, the refresh is available.

I have 1 base activity and 3 fragments. The fragments are hidden and shown using a fragment manager according the the program state. In some cases, one fragment will cover the entire space of the activity. in other cases 2 fragments will sit side by side and collectively cover the entire space of the activity.

When I implement the SwipeRefreshLayout on the fragment level, the refresh functions correctly, however in the case where I have 2 fragments side by side, the spinner will be centered to the fragment rather than the activity.

When I Implement the SwipeRefreshLayout on the Activity Level, the Fragments absorb the gesture events and the SwipeRefreshLayout is unresponsive.

What I want to have happen is a downward swipe anywhere in the side by side fragments layout to bring the refresh loading spinner down in the center according to the activity rather than the fragment. For this to happen, either I need to find a way to implement the SwipeRefreshLayout on the activity level where it will pickup on motion events observed in the fragments or I will need to implement the SwipeRefreshLayout on the fragment level and find a way to center the Loading spinner.

If anyone knows how to do either case, I would greatly appreciate the help.

Aucun commentaire:

Enregistrer un commentaire