react-native android fontFamily无效 [英] react-native android fontFamily does not take effect
问题描述
我在index.android.js的欢迎样式中添加了fontFamily,但是没有效果.fontFamily确实可以在android上运行吗?
I add a fontFamily to index.android.js's welcome style, but it takes no effect. Does fontFamily actually work on android?
欢迎:{fontSize:20,fontFamily:'roboto-thin',textAlign:'居中',保证金:10}
welcome:{ fontSize:20, fontFamily:'roboto-thin', textAlign:'center', margin:10}
如果fontFamily在android上有效,是否可以从资产加载自定义字体?还是该功能由react-native实现?
if fontFamily works on android, is there a way to load custom font from assets? Or is this some feature to be implemented by react-native?
推荐答案
对于Android:自定义字体添加了0.16.0-rc.因此,您首先需要拥有0.16.0-rc版本,然后您可以从网络上下载任何字体.
For Android: Custom fonts were added with 0.16.0-rc. So you need to have 0.16.0-rc version first and after that you can just download any fonts from the web.
- 将字体文件放入projectfolder/android/app/src/main/assets/fonts/font_name.ttf
- 记住要重新编译,即:
react-native run-android
- 然后您就可以在样式中使用
fontFamily:'font_name'
.
这篇关于react-native android fontFamily无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!