I have a simple app that displays text.
The app starts with a main screen with a few options (ex. an info button that leads to info about the app, a browse button th
In the activities where you want to have no action bar use a theme derived from Theme.AppCompat.NoActionBar
or Theme.AppCompat.Light.NoActionBar
. This activity will never be able to show the action bar unless you supply your own via setSupportActionBar(Toolbar)
.
In the activities where you want to have the action bar use a theme derived from Theme.AppCompat
, Theme.AppCompat.Light
or Theme.AppCompat.Light.DarkActionBar
. This will allow you to dynamically hide or show the action bar in such activity. You will not be able to supply your own action bar using these themes.
When working with appcompat-v7 action bar you need to obtain it by calling getSupportActionBar()
instead of getActionBar()
.
You can hide and show the ActionBar programatically.
To hide
getSupportActionBar().hide();
To Show
getSupportActionBar().show();
It can also be done from Fragments
To hide
getActivity().getSupportActionBar().hide();
To Show
getActivity().getSupportActionBar().show();
Edit:
As noted by @RenniePet,
You need to call ((AppCompatActivity)getActivity()).getSupportActionBar()
, if you're using Toolbar
as the ActionBar
.
I hope this can be solution. It worked on my system:
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"