Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove app title from toolbar?

Tags:

I can't figure out how to remove my title. I've used the code below in my MainActivity but after I added that line, my app crashes.

getSupportActionBar().setDisplayShowTitleEnabled(false); 

Here is how my MainActivity looks:

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); 

Full code:

 @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);         setSupportActionBar(toolbar);         setContentView(R.layout.activity_main);         setTheme(R.style.CustomTheme); 
like image 681
yoshatabi Avatar asked Jun 28 '15 04:06

yoshatabi


People also ask

How do I remove the title from my toolbar?

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.

How do I hide app names on my toolbar?

To remove the title bar/ action bar from your Android application, you can set the <style> tag in your application to NoActionBar .

Which method is used to hide the activity title?

Just use getActionBar(). hide(); in your main activity onCreate() method.


1 Answers

Try this,

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);         setSupportActionBar(toolbar);         getSupportActionBar().setDisplayShowTitleEnabled(false);         //toolbar.setNavigationIcon(R.drawable.ic_toolbar);         toolbar.setTitle("");         toolbar.setSubtitle("");         //toolbar.setLogo(R.drawable.ic_toolbar); 

If still doesn't works just use setNavigationIcon() & setLogo() and that should replace the title. If you are facing any crashes please post the crash report.

like image 186
Prokash Sarkar Avatar answered Nov 01 '22 16:11

Prokash Sarkar