Reputation: 17753
I am solving this issue. I need to set up custom font in titlebar, but my activity is using dynamically generated layout (thus setContentView(R.layout.somtehing
) is not used).
I have tried, that to set up custom font in titlebar you can do that by these code:
type = Typeface.createFromAsset(getAssets(),"fonts/verdanab.ttf");
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.something);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.gal_title);
title = (TextView) findViewById(R.id.title);
title.setText(R.string.Text);
title.setTypeface(type);
Problem is, this code doesn't work, app doesn't see TextView
title, because there isn't setContentView()
. Any advices?
Thx
Upvotes: 1
Views: 1679
Reputation: 12134
Initialize this line type = Typeface.createFromAsset(getAssets(),"fonts/verdanab.ttf");
after this line
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.gal_title);
Use this code,
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.something);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.gal_title);
Typeface type = Typeface.createFromAsset(getAssets(),"fonts/verdanab.ttf");
title = (TextView) findViewById(R.id.title);
title.setText(R.string.Text);
title.setTypeface(type);
Upvotes: 1