Reputation: 107
I wanted to know how to add my own custom font to the app name that appears in the action bar in android studio.
Upvotes: 0
Views: 326
Reputation: 1977
You can set CustomLayout in ActionBar
this.getActionBar().setDisplayShowCustomEnabled(true);
this.getActionBar().setDisplayShowTitleEnabled(false);
LayoutInflater inflator = LayoutInflater.from(this);
View v = inflator.inflate(R.layout.titleview, null);
//if you need to customize anything else about the text, do it here.
//I'm using a custom TextView with a custom font in my layout xml so all I need to do is set title
((TextView)v.findViewById(R.id.title)).setText(this.getTitle());
//assign the view to the actionbar
this.getActionBar().setCustomView(v);
You can assign the custom font to textview by using setTypeFace()
Upvotes: 1
Reputation: 30985
I did this by just making an image of the app name with the custom font then displaying the image as the logo in the action bar. Much simpler.
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayUseLogoEnabled(true);
actionBar.setLogo(R.drawable.app_logo);
Upvotes: 0