The documentation of Toolbar
says
If an app uses a logo image it should strongly consider omitting a title and subtitle.
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);
I dont know whether this is the correct way or not but I have changed my style like this.
<style name="NoActionBarStyle" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
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 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
toolbar.setTitle(null);
// remove the title
Just adding an empty string in the label
of <application>
(not <activity>
) in AndroidMenifest.xml
like that -
<application
android:label=""
android:theme="@style/AppTheme">
<activity
.
.
.
.
</activity>
</application>