How can I hide action bar for certain fragment? I have searched for the answer at stackoverflow, but I have only found a solution, which involves disabling action bar for main activity in android manifest. Since I need to disable action bar for one fragment, this is not an option. Any ideas? Thanks.
EDIT: min API level is 7, sherlock is not being used
If you want to hide Action Bar throughout the app (Activities, Fragments) everywhere, you can simply navigate to res > values > styles.
When you click the show button to open a fragment, you can see the fragment menu items ordered before activity menu items. This is because of the menu item's android:orderInCategory attribute value. When you click the hide button to hide the fragment. The fragment menu items disappear from the action bar also.
If you want to hide Action Bar from the entire application (from all Activities and fragments), then you can use this method. Just go to res -> values -> styles. xml and change the base application to “Theme.
The requestWindowFeature(Window. FEATURE_NO_TITLE) method of Activity must be called to hide the title.
If you are using AppCompatActivity (you should) then this is the solution that worked for me:
((AppCompatActivity) getActivity()).getSupportActionBar().hide();
You can add this in onCreate(). The support fragment's getActivity() returns a FragmentActivity, and this does not contain the getSupportActionBar() method. Using just getActionBar() gives null-pointer exception if you have AppCompatActivity.
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