简体   繁体   中英

How to change font of TextView?

I have textview. I could not show japanese characteristics. So downloaded font to Assets/fonts folder. I tried this code

Typeface tf = Typeface.createFromAsset(getAssets(),
            "fonts/ipag.ttf");
    TextView tv=(TextView) findViewById(R.id.name);
    tv.setTypeface(tf);

But application not working. What should be changed?

This code has work for me:

first declare the font:

Typeface font;

second inside the onCreate:
font = Typeface.createFromAsset(getAssets(), "myfont.ttf") ;

third: also inside the onCreate:

myTest = (Button) findViewById(R.id.myTest);
myTest.setTypeface(font);

My application can change the languaje and japanesse in one of those, and it works well. This is the font used: http://wowslider.com/styles/miso-bold-webfont.ttf .
by the way, the font is inside the Assets folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM