I set typeface in run time .But it is not reflecting in my application.
package com.example.practice;
import android.os.Bundle;
import android.app.Activity;
import android.graphics.Typeface;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Typeface font = Typeface.createFromAsset(getAssets(), "fonts/Windsong.ttf");
View customActionBar=getLayoutInflater().inflate(R.layout.activity_main, null);
TextView actionBarTitle=(TextView)customActionBar.findViewById(R.id.helloworld);
actionBarTitle.setTypeface(font);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
I am Expecting the following font.

But i am getting the following output.

Try this.
TextView actionBarTitle=(TextView)findViewById(R.id.helloworld);
actionBarTitle.setText("HelloWorld");
actionBarTitle.setTypeface(font);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With