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.
androidx.appcompat.widget.Toolbar. A standard toolbar for use within application content. A Toolbar is a generalization of action bars for use within application layouts.
getSupportActionBar().setDisplayShowTitleEnabled(false);
The correct way to hide/change the Toolbar Title is this:
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(null);
This because when you call setSupportActionBar(toolbar);
, then the getSupportActionBar()
will be responsible of handling everything to the Action Bar, not the toolbar object.
See here
Try this...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_landing_page);
.....
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_landing_page);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
.....
}
The reason for my answer on this is because the most upvoted answer itself failed to solve my problem. I have figured out this problem by doing this.
<activity android:name="NAME OF YOUR ACTIVITY"
android:label="" />
Hope this will help others too.
Another way to remove the title from your Toolbar
is to null
it out like so:
Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
toolbar.setTitle(null);
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