In my app I set the toolbar and status bar as shared objects as suggested in option #2 in this post
The general behavior and outline of the toolbar and tabs are excellent - the only issue is that when I move to activity B, some of the UI elements of the Toolbar are not participating in the content transition, particularly the Toolbar title and the menu icons.
I tried adding a SharedElementCallback and in it to loop over the children of the toolbar and tabs and add them all to a Fade transition - but it didn't affect the behaviour of the toolbar and tab content.
Any idea how to proceed from here? The desired effect is to have the elements of the Toolbar (title, up button, menu icons) participate in the content transition.
Added screenshots after comment:
Activity A
Activity B
On Android 4.1 and higher, you can set your application's content to appear behind the status bar, so that the content doesn't resize as the status bar hides and shows. To do this, use SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN . You may also need to use SYSTEM_UI_FLAG_LAYOUT_STABLE to help your app maintain a stable layout.
It will delegate the functionalities related to your defined toolbar. It helps activity to understand the many of the requirements some of them mentioned below.
Status bar (or notification bar) is an interface element at the top of the screen on Android devices that displays the notification icons, minimized notifications, battery information, device time, and other system status details.
Each activity has your own menu, so you have to create the menu for each one, even if they are the same.
However, if you prefer, you can create just one menu and create a custom class for manipulate the menu; Then you call this custom class on onCreateOptionsMenu
and onOptionsItemSelected
from whatever activity.
The following code is an example.
Custom class:
public class MenuActionBar {
public static void createOptionsMenu(final Activity activity, Menu menu) {
activity.getMenuInflater().inflate(R.menu.yourmenu, menu);
// Do whatever you wanna do
}
public static boolean optionsItemSelected(Activity activity, MenuItem item) {
// Do whatever you wanna do
}
}
Activity:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuActionBar.createOptionsMenu(this, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
return MenuActionBar.optionsItemSelected(this, item)
? true : super.onOptionsItemSelected(item);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With