android - 如何在android中将字体设置为textview?

标签 android textview

我正在这样做,但它变得很接近。我想更改 textview 字体

TextView mWeddingDataandTime=(TextView)findViewById(R.id.wedding_weddingtime_txt);
Typeface face=Typeface.createFromAsset(getAssets(),"fonts/CURLZ_.otf"); 
mWeddingDataandTime.setTypeface(face); 

我正在使用 .otf 文件。它位于 Assets 文件夹中。有什么想法吗?

最佳答案

试试这个:

    TextView txt = (TextView) findViewById(R.id.custom_font);
    Typeface font = Typeface.createFromAsset(getAssets(), "Chantelli_Antiqua.ttf");
    txt.setTypeface(font);

请注意,文件扩展名是“ttf” 在谷歌中搜索此扩展名中的任何字体以供下载

例如: http://www.creamundo.com/

关于android - 如何在android中将字体设置为textview?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9684345/

相关文章:

android - 通过XML将所有TextView设置为不可见

android - 具有多个条件的 SQL Android 查询公式

android - 如何从现有的 react-native 项目生成 AndroidManifest.xml?

android - 如何在不同的 fragment 中设置 ActionBar 项目的可见性

android - android studio 中不是全宽工具栏?

android - 如何解析从 EditText 到 TextView 的 double ? (安卓)

android - 如何使用 Android 提供的(自定义)字体?

android - 有没有办法像日历应用一样动态更改应用图标?

android - 不可分配给 android.app.activity

android - 使用 span 在 textview 中插入标签