0

I'm working on an app that is already in production, it has multiple activities. The designers now want to add a Floating Action Button which is anchored to the bottom-right of two of our activities (possibly more in future). The FAB needs to remain at the same spot when the two activities transition between each other.

I know I can use shared element transition to achieve this, but the problem is we are using overridePendingTransition() to add a sliding animation when transitioning between the two activities, and that sliding animation gets broken when I use shared element transition as it gets overridden by the scene transition animation.

Has anyone had to do something similar?

To summarise, here are my requirements:

  1. two activitie transition between each other using a sliding animation
  2. a floating action button is in both activities, in the same location
  3. the FAB needs to remain stationary at all times, including during the transition between the two activities
  4. the FAB can but doesn't need to respond to onClick events during transition (this is an acceptable limitation)
  5. I don't care how dirty the implementation is, but I would strongly prefer not to refactor into a single activity because both activities are quite complex as they are

Happy to provide any additional details if it helps. Thanks.

qtyq
  • 92
  • 4
  • use fragments instead of activities and you can have shared FAB button. – SriMaharshi Manchem Aug 17 '17 at 05:03
  • @SriMaharshiManchem I know, I'm already using fragments in each of the activities. But like I said the two activities are very complex so I'd rather not do that just to achieve this. – qtyq Aug 21 '17 at 08:05

1 Answers1

0

Actually, I don't have similar case to you. I am working on multiple fragments rather than activities. What you can do is create a base activity which implement the fab button and extend that base activity in the other two activities.

For the respective work of fab button in each activity, you can do that with the help of string in savedInstanceState i.e from Bundle.

Hope it helps!!

Rishav Chudal
  • 171
  • 1
  • 8
  • Sorry I don't see how this would help compared to adding the FAB to both activities (which I've already done for now), but thanks anyway. – qtyq Aug 21 '17 at 08:06
  • when a base activity is extended in both activities, the method call for fab button in both activities can be made same or different according to the choice. Its working perfectly when I have multiple fragments under a base activity extended activity. It can reduce code boilerplate and I think the fab button will remain stationary. – Rishav Chudal Aug 22 '17 at 11:03