[英]How to change font of TextView?
I have textview. 我有textview。 I could not show japanese characteristics.
我看不出日本特色。 So downloaded font to Assets/fonts folder.
因此将字体下载到Assets / fonts文件夹。 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: 第二个onCreate:
font = Typeface.createFromAsset(getAssets(), "myfont.ttf")
; font = Typeface.createFromAsset(getAssets(), "myfont.ttf")
;
third: also inside the onCreate: 第三:也在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. 我的应用程序可以更改其中的languaje和japanesse,并且效果很好。 This is the font used: http://wowslider.com/styles/miso-bold-webfont.ttf .
这是使用的字体: http : //wowslider.com/styles/miso-bold-webfont.ttf 。
by the way, the font is inside the Assets folder. 顺便说一句,字体在Assets文件夹中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.