0

I wanted to know how to add my own custom font to the app name that appears in the action bar in android studio.

Tim
  • 41,901
  • 18
  • 127
  • 145

2 Answers2

1

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()

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Ashish Agrawal
  • 1,977
  • 2
  • 18
  • 32
0

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);
kris larson
  • 30,387
  • 5
  • 62
  • 74