android - 文本字体样式不出现

标签 android text-styling

我正在开发一个使用漫画字体的应用程序,可以从 Assets 文件夹中获取它。现在我想把文字加粗。所以我简单地使用:

 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 上没有出现粗体样式

最佳答案

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

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

关于android - 文本字体样式不出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6896826/

相关文章:

android - 如何在具有 armeabi-v7a 架构的手机上测试为 arm64-v8a 架构编译的应用程序?

android - 如何在 SherlockFragmentActivity 类中设置 actionbarsherlock 的 CustomView

android ndk : are -fPIC and -pie mututally exclusive?

android - 如何在 Android TextView 中将字体样式设置为粗体、斜体和下划线?

html - 将 !important CSS 样式应用到 div,而不是子元素

javascript - 使用 Javascript 清除元素的文本样式

qt - “text-overflow” 用于 QT 中 QLabel 的文本渲染

android - NFC读卡器获取错误android

java - 如何将数据字符串存储到数组中

ios - NSAttributedString 中的一个单词有两种不同的颜色