fonix232 fonix232 - 1 year ago 141
Android Question

AppCompat ActionBar restoring original layout

In my app, I use a MainActivity for storing the main layout (DrawerLayout, with a CoordinatorLayout as content root, with the toolbar and fragment holder in it), and various fragments as screens.

On one particular screen I'd like to expand the ActionBar to a certain size, and give it specific content (remove the toggle button, menu bar, etc., and specify my own layout). It is done by

. It works pretty well, however when I navigate to a different fragment, I'd like to restore the original layout. Is there a simple way of doing this?

Answer Source

Yes, in order to remove your custom view and restore the AppCompat ActionBar you can call setDisplayOptions.

getActivity().getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download