I have a Toolbar with text "App de prueba" and a menu icon, but the app name is on the left side, how can delete the app name?
Thanks!
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
Just call the setTitle() method in your activity's onCreate and pass an empty String in it - setTitle("") (assuming you are using a custom layout as title in your toolbar). You cannot remove or change the visibility of the title view in the activity as the id of this view is not public. There are ways by which you can still access the id by using reflection but that makes the code messy and therefore is not needed.
Related
When I start the app I want to display the app name as a placeholder. After getting the user's info, I want to change the title to a variable related to this user.
If I initially do this:
toolbar = findViewById(R.id.toolbar);
toolbar.setTitle("");
setSupportActionBar(toolbar);
And then after a while do this:
toolbar.setTitle(user.getName());
It works fine.
But! If instead of setting the title to an empty string I set it to a non empty string it doesn't work. I assume Android is checking if the title is empty before placing it or something. Is there a way to get this to work?
Call setSupportActionBar(toolbar); again after setting toolbar title with user's name.
toolbar.setTitle(user.getName());
setSupportActionBar(toolbar);
I use :
getSupportActionBar().setTitle("New title");
and it works. Give it a try.
Seems pretty simple question, but could't find any answer.
How to change the toolbar title.
The toolbar is created by AppCompat Activity,not a custom created one.
It has the app name as default.I would like to change its Name corresponding to the action the activity performs.
Note : I can change custom toolbar title using the below code,so please i am not looking for that.
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setTitle("My Title");
You can set default Toolbar title as following:
YourActivity.this.setTitle("Your Title");
For fragment:
getActivity().setTitle("Your Title");
getSupportActionBar().setTitle("Title")
Set ActionBar title based on your need
ActionBar ab = getActionBar();
ab.setTitle("My Title");
Can please someone tell me how to change the App name in the top bar of my android App that gets displayed by default to some other text? I have seen this in a few Apps I used before. I'm building my first Android App and don't have that much experience with this stuff... thank you :)
after
setContentView(R.layout.layout_name);
simply add
setTitle("title_name");
this will change the name of your current activity in top bar or toolbar and i think your activity should extend AppCompactActivity
it is easier if you convert the actionbar (which I think is the bar you mean) into a toolbar if you want to do further modifications to it (as I assume):
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
to change the title then simply call actionbar.setTitle as shown here:
actionBar = getSupportActionBar();
actionBar.setTitle("Your Title");
and if you want a subtitle add:
actionBar.setSubtitle("Your Subtitle");
If you are using the new support library, you should use this:
Toolbar toolber = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(Toolbar);
getSupportActionBar().setTitle("App Title");
I have a hard time finding on how to change the Toolbar title and it's drawable in every and each Activity.
There is something on Android Documentation that states that to minimize APK size. It is recommended to re-used components.
I create a separate layout, and <include layout=""/> to each of my Activities like Help, About , and etc. I also put android:label="Title" on Manifest File.
Toolbar.xml
My Main:
How do I access this included Toolbar DRAWABLE and TITLE in my Activities ?
Update: I removed ActionBar .
You are using Toolbar. So no need to do anything with ActionBar. Just set your Toolbar as supportActionBar. Then set title and icon to your Toolbar.
Use the below code:
mToolbar = (Toolbar)findViewById(R.id.Toolbar);
setSupportActionBar(mToolbar);
setTitle("About");
getSupportActionBar.setIcon(R.id.ic_arrow_back_black_24dp);
And, Remove all your mActionBar codes. Hope this helps.
well you set the support action to your custom toolbar,yet you ignore it and use mActionBar, see where i am going with this? setIcon , and setTitle should all be called relative to your custom toolbar.
How can I add app logo as well as app name?
I tried, but either logo appears or app name, not both.
Have you tried setTitle() and setNavigationIcon()?
Toolbar toolbar=(Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle("Title");
toolbar.setNavigationIcon(R.drawable.some_icon);
Just simple way :
Toolbar toolbar=(Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if(getSupportActionBar()!=null){
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(drawerArrowDrawable);
getSupportActionBar().setIcon(R.drawable.ic_label_black_48dp);
}
You will see a screen like that :