Vicky
Vicky

Reputation: 170

Put typeface to textview in android dynamically

I am new to android. I have a textview and want to assign custom font to it. My font file (*.ttf) is on the server. I have to use that file in code to set font dynamically (on the fly). I don't want to put the file in asset folder or any raw folder. How can this be implemented?

Upvotes: 2

Views: 1439

Answers (2)

Ken Wolf
Ken Wolf

Reputation: 23279

  1. Download font from server
  2. Save to SD card
  3. Use Typeface.createFromFile(String path)
  4. textView.setTypeface(yourTypeface);

Upvotes: 2

sarthakmeh
sarthakmeh

Reputation: 90

you need to add your font file to asset folder and then use this in your java code.

Typeface temp = Typeface.createFromAsset(getAssets(), "fonts/RadioLand.ttf");

  bat = (TextView)findViewById(R.id.textView1);
    bat.setTypeface(temp);

Upvotes: 0

Related Questions