文本不显示字体样式

时间:2011-08-01 10:01:03

标签: android text-styling

我正在开发一个使用漫画字体的应用程序,可以从资源文件夹中获取。现在我想把文字加粗。所以我只是使用:

 Typeface face=Typeface.createFromAsset(this.getAssets(), "fonts/comic.TTF"); 
    la = (TextView) findViewById(R.id.la);
    la.setText("Dog");

    la.setTextAppearance(getApplicationContext(),R.style.boldText);
    la.setTypeface(face); 

String.xml

  <?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="hello">Hello World, timerTest!</string>
    <string name="app_name">timerTest</string>

    <style name="boldText">
        <item name="android:textStyle">bold</item>

    </style>
</resources>

所以问题是当我运行项目comic.ttf得到正确但粗体样式没有出现在text

1 个答案:

答案 0 :(得分:1)

Typeface face=Typeface.createFromAsset(this.getAssets(), "fonts/comic.TTF"); 

        la = (TextView) findViewById(R.id.la);
        la.setText("Dog");
        la.setTypeface(face,Typeface.BOLD);