2011-08-01 55 views
1

我正在開發一個應用程序,其中使用了漫畫字體,可以從資源文件夾中獲取該字體。現在我想將文字加粗。於是我簡單地使用:不顯示文本字體樣式

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

我認爲當我們使用自定義字體,然後我們不能使用任何字體樣式... –

回答

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

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