0

I want to implement different font in different TextViews.

I am trying to implement fonts from assets with this.

tf = Typeface.createFromAsset(v.getContext().getAssets(), "Roboto.ttf");
bellow_name.setTypeface(tf);

But I have TextView something like this

((TextView) findViewById(R.id.news_date)).setText(news.news_date);

How can I implement Typeface with above TextView?

marc_s
  • 704,970
  • 168
  • 1,303
  • 1,425
user8663248
  • 25
  • 1
  • 7

2 Answers2

0

1.create a new fonts directory in the assets directory and put the Roboto.ttf font file here.

You can change to this .

tf = Typeface.createFromAsset(v.getContext().getAssets(), "fonts/Roboto.ttf");
bellow_name.setTypeface(tf);
KeLiuyue
  • 7,831
  • 4
  • 23
  • 39
0

Just create a object of TextView set type face with that

TextView bellow_name = (TextView) findViewById(R.id.news_date);
Typeface tf = Typeface.createFromAsset(v.getContext().getAssets(), "Roboto.ttf");
bellow_name.setTypeface(tf);
bellow_name.setText(news.news_date);

If you have sub folder in Asset folder you have to add that. suppose...

assets(directory)
   -fonts(directory)
      -Roboto.ttf
      -Comics.ttf

Then change path like this

Typeface tf = Typeface.createFromAsset(v.getContext().getAssets(), "fonts/Roboto.ttf");