I want to set toolbar on my activity which extends FragmentActivity. I know that for use setSuppoertActionBar(toolbar)
method we e
This thing is good when you are using NavigationDrawer
use this:-
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
then set Toolbar Title according to different fragment with different Titles in onNavigationItemSelected
:-
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
sfm = getSupportFragmentManager();
Fragment fragment = new Fragment();
int id = item.getItemId();
if (id == R.id.nav_id) {
fragment = new YourFragment();
toolbar.setTitle("SET TOOLBAR NAME");
}else if (id == R.id.nav_id2) {
fragment = new YourFragment();
toolbar.setTitle("SET TOOLBAR NAME");
}
For single fragment, first customize your style.xml
like this :-
then apply into your custom toolbar
:-
// ...........