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.
getSuppor
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.
This is my gradle:
android {
compileSdkVersion 26
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.example.zumoappname"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
and this is my activity:
public class MainActivity extends AppCompatActivity {
.....
The following code works very nice for me:
Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
myToolbar.setTitle("");
setSupportActionBar(myToolbar);
This line is just important
getSupportActionBar().setDisplayShowTitleEnabled(false);
You can use toolbar.setTitle(""); Or you can simply set the android:label="" for your Activity in the AndroidManifest.xml
Add this line to your AppTheme
in styles.xml
:
<item name="windowActionBar">false</item>
Try this:
getSupportActionBar().setDisplayShowTitleEnabled(false);