0

I want to make slideable panels with content lying beneath them. The idea is sort of like this in my mind, but I'm not sure of how to approach this.

enter image description here

That triangles in the layer 2 can be used to pull or push (slideable animation).

Can anyone drop me a hint or if there's any existing approaches on something like this? If you didn't understand it completely or want some more specific information, feel free to comment.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Ketan Malhotra
  • 1,255
  • 3
  • 16
  • 44

1 Answers1

1
  1. You can have a single layout and use the Right-to-Left exit and Left-to-Right animation as provided here
  2. You can use a ViewPager to implement this.
ABS
  • 1,101
  • 10
  • 27
  • Looks like that will work for me :D Thanks for the hint. Any idea how I can make it so that I can control the animation with my finger being pressed on it. As if, if I pause my finger half-way (while keeping it pressed), how can I pause the animation right there? – Ketan Malhotra Aug 01 '17 at 14:53
  • In that case, you can go with the first approach and use SimpleOnGestureListener. Here's how you can use it: https://developer.android.com/training/gestures/detector.html – ABS Aug 01 '17 at 18:10
  • And what shall I use to move the object? Translation animation or there's something better in that case? – Ketan Malhotra Aug 01 '17 at 18:14
  • You don't need that with SinpleOnGestureListener. You can manually move the view once you start getting events after you implement this: – ABS Aug 01 '17 at 18:20
  • @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { // store position of the initial touch break; } case MotionEvent.ACTION_MOVE: { // calculation and transformation here swipeListener.onSwipeMoved(absoluteDx, absoluteDy, viewWidth, viewHeight); break; } case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: swipeListener.onSwipeEnded(viewWidth, viewHeight); break; } } – ABS Aug 01 '17 at 18:20
  • I think that'd be exactly what I need. Thanks! – Ketan Malhotra Aug 01 '17 at 18:21