Reputation: 802
This is my app:
Now i want to remove the app name from my ActionBar...
I want it like this:
my code:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/phone"
android:title="@string/phone"
android:icon="@drawable/phone"
myapp:showAsAction="ifRoom" />
<item
android:id="@+id/computer"
android:title="@string/computer"
android:icon="@drawable/computer"
myapp:showAsAction="ifRoom" />
</menu>
Upvotes: 13
Views: 15049
Reputation: 1
Nowadays you can just set this inside the onCreate
supportActionBar?.hide()
Upvotes: 0
Reputation: 1
Just write this:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getSupportActionBar().hide();
setContentView(R.layout.activity_main);
}
Upvotes: 0
Reputation: 21
For Android 4.2.1 edit the default theme NoActionnBar and add this code in MainActivity.java file
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (getSupportActionBar() != null) {
getSupportActionBar().hide();
}
}
Upvotes: 2
Reputation: 1082
I've seen some questions about the location etc. Here is the complete solution. Use this in onCreate();
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// Set title to false AFTER toolbar has been set
try
{
getSupportActionBar().setDisplayShowTitleEnabled(false);
}
catch (NullPointerException e){}
Upvotes: 4
Reputation: 101
If you want to hide it use this code
getSupportActionBar().setDisplayShowTitleEnabled(false)
or if you want to change the name use this
getSupportActionBar().setTitle("type yor title here");
Upvotes: 6
Reputation: 14031
You could try setTitle("")
. If you are using ActionBar
or ToolBar
, then call bar.setTitle("")
or :
bar.setDisplayShowTitleEnabled(false);
bar.setDisplayShowHomeEnabled(false);
Upvotes: 1
Reputation: 187
Call setDisplayShowHomeEnabled() and setDisplayShowTitleEnabled() on ActionBar, which you get via a call to getActionBar().
Upvotes: 2
Reputation: 720
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
Or you can just call actionbar.setTitle("")
Upvotes: 25