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);
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.
To remove the title bar/ action bar from your Android application, you can set the <style> tag in your application to NoActionBar .
Just use getActionBar(). hide(); in your main activity onCreate() method.
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.
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