1

In Android (22+), I'm looking for a library or a 'tried & tested approach' to give the setup that allows an app to overlay 1 fragment on top of another that and would also provide gesture drag in/out along with peeking behind(see animation below)?

Criteria;

  • library to animate the swipe-in/out
  • handles the darkening the background fragment the further you drag in
  • the overlay fragment is there to provide context information to the user)

Further to @Rainmakers suggestions, I have a 'nearly working' approach were that I have an overlay fragment that is added to the top of the fragment stack; were then I have applied a touch gesture on the overlay fragment to dismiss on a left->right swipe capture. This Works and looks ok and 'will do' but would like the peek behind the feature that is shown in the animated GIF.

This animation was taken from the google drive android app;

Demo

Mostafa Arian Nejad
  • 1,278
  • 1
  • 19
  • 32
Mannie
  • 1,608
  • 1
  • 21
  • 33

1 Answers1

0

If you're eager to use a library then check this out FragmentTransactionExtended. It has different slides.

Then you just override the onTouchEvent() method (check how to do it link) and do fragment transactions when swipe is caught. If you use add in the transaction you won't dispose the fragment underneath.

And the part with darkening you should also manage it in onTouchEvent(). See this to make your fragment grey out.

Rainmaker
  • 10,294
  • 9
  • 54
  • 89
  • Thanks; i'll check out the library - will the onTouchEvent() approach give me the swipe animation when my finger 'drags' the on-top fragment in/out of view ?? – Mannie Mar 31 '18 at 15:33
  • the library will give you the animation, and onTouchEvent will detect when you should start the transaction with animation. And the grey out is just the additional trick you can add – Rainmaker Mar 31 '18 at 15:40