Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Can we hide title bar while using action bar?

I'm using ActionBarSherlock and I'm trying to hide the title bar of my application but whenever I do that, I get a NullPointerException when accessing the ActionBar How do I remove/hide the title bar? Please note that I'm not referring to the title of the action bar. I'm referring to the title bar above the action bar. I'm running my application on an Android 2.3 device.

Below is my code: (My class extends SherlockFragmentActivity.)

super.onCreate(savedInstanceState);
setTheme(R.style.Theme_Sherlock);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
ActionBar actionbar = getSupportActionBar();
actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); //I get the NullPointerException here.

//...

setContentView(R.layout.tab_navigation);
like image 930
Arci Avatar asked Nov 23 '12 03:11

Arci


People also ask

How do I hide action bars?

If you want to hide Action Bar throughout the app (Activities, Fragments) everywhere, you can simply navigate to res > values > styles.

How do I hide the title bar on my laptop?

To hide the Title Bar using the Android Manifest. xml file you need to set the Android theme to NoTitleBar like this: android:theme="@android:style/Theme. NoTitleBar">

How do I remove the title bar from Kotlin?

Another way for removing the title specifically from an activity is by using a getSupportActionBar(). hide() method. Inside the activity's kotlin file, we need to invoke getSupportActionBar(). hide() method.


2 Answers

I hide the title bar by adding the following lines of code:

getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayShowHomeEnabled(false);

hope this helps :)

like image 180
Razel Soco Avatar answered Sep 28 '22 17:09

Razel Soco


to hide all the title bar and keep only the action bar use this code:

final ActionBar actionBar = getActionBar();
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayUseLogoEnabled(false);

it worked for me

like image 22
Khaledvic Avatar answered Sep 28 '22 16:09

Khaledvic