Adding a shared floating action button to two existing activities - android

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:
two activitie transition between each other using a sliding animation
a floating action button is in both activities, in the same location
the FAB needs to remain stationary at all times, including during the transition between the two activities
the FAB can but doesn't need to respond to onClick events during transition (this is an acceptable limitation)
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.

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!!

Related

Android, Cicerone. Is it possible to implement cicerone with bottom navigation and Single Activity approach?

I'm using cicerone and single activity approach. When the application starts, the first three seconds I'm showing splash fragment inside my activity and so redirect to home fragment. Now I need to add to my application bottom navigation. Is it possible to add bottom navigation using single activity approach and cicerone. Or will I have to add another activity for the holding bottom navigation ?
Unfortunately, I could not find examples of projects with cicerone, single activity and bottom navigation.
My main goal is to save single activity, please tell me if it is possible to achieve this ?

Bottom Navigation with Activity

I have an application where it is required to persist the bottom navigation across multiple screen. Now naturally bottom navigation works well with fragments but the problem is that my other fragments also have other screens to call which is usually delegated back to the handling activity.
With said, when i tried implementing the bottom navigation with fragments the activity becomes a God Activity where it handles all fragments.
So my solution was to start an activity instead. But the problem with this approach is that every start of the activity the activity transition makes it obvious an activity is being started. I tried setting off the activity transition to avoid this but now Im left with a very static page which just suddenly changes. I still want my views to animate smoothly between screen changes.
Can someone give me an advice here. Heres what I would want to achieve in summary:
1) make it seem the bottom navigation was not changed/moved (and hopefull still have the shifting animation if possible)
2) animate smoothly between screen changes
3) also still have the capability of having shared element transition if possible.
Please help me here. Thank you so much in advance.

How do i make my Floating Action Button(FAB) to visible in all the screen of app not just the page viewer

I want to make my FAB to be visible throughout the app.
I have pageviewr and im able to display FAB in all pageViewer.
- FAB works same in all the screen so.
Even i have different activity too, i want to display in those activity too.
can any let me how do i do that.
Or do i need to add the FAB button in different activity ?
Every activity in Android has its own content View, so you need to add FAB to each one.
But if you want to reduce duplications, you can make fab_layout.xml with <include> tag and use it for every layout every Activity.
Also you can implement Base activity, with providing base functionality to FAB. Or instead of parent Base activity you can implement FabHandler class and use it in each activity.

Avoid Tabs from disappearing when searching

i've got a tabbed layout, and on one of the tabs i have a search functionality. When the user makes a new search, i need to show the results. However, doing so involves starting another activity to handle the search results.
this causes the tabs at the bottom to disappear. The user can get the tabs back by clicking on the 'back' button. But somehow, in the context of my application this can be a bit counter-intuitive and seems to be break the common layout flow.
is there any way to prevent the tabs from disappearing when invoking the search from one of the tabs?
thanks for any help/suggestions.
as far as i can understand your problem, You are not using tabs then you are using buttons. see some tabhost tutorials on how to create a tabbed activity. what you are doing is launching a new activity instead of just switching a tab in the existing one.
Also the other things you can look for are activity groups.
Hope this helps you somehow.

Layout issue - how to start an activity without moving certain UI elements?

I'm trying to implement tab buttons bar and a navigation bar in my android application. The problem is, that I would like the navigation elements to persist. When starting a child activity, the nav bar moves.
How can I make these two elements "non-movable"?
Add button bar and navigation bar to all your activities and share it's state via static fields. Remember to initialize bars when child activity starts and update parent's bars when child activity finishes (either via onResume or as a result of startActivityForResult).
It is not possible to share instances of UI elements between activities, as Activities are (by design) independent of each other.
Application cannot control how new activity is introduced - it can slide, zoom in or just show up if user disable animation in device preferences, UPDATE: it looks like since API Level 5 there are ways to override this, please refer to Activity transition in Android . But if you really need to keep bars in place, use single Activity and replace main view content with animation you like.

Categories

Resources