Adz*_*bar 5 android react-native react-native-android
我想要在 react-native 选择器上使用 style font-size 和 font-family 。我已经在原生 android 上设置了自定义样式。但是在我再次构建 apk 之后没有改变它仍然是相同的字体。
我在 style.xml 上的代码
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:spinnerItemStyle">@style/SpinnerItem</item>
</style>
<style name="SpinnerItem" parent="Theme.AppCompat.Light.NoActionBar">>
<item name="android:fontFamily">CenturyGothicBold</item>
<item name="android:textSize">16dp</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
小智 0
尝试下面的代码:
TextView tx = (TextView)findViewById(R.id.textview1);
Typeface custom_font = Typeface.createFromAsset(getAssets(), "fonts/CenturyGothicBold.ttf");
tx.setTypeface(custom_font);Run Code Online (Sandbox Code Playgroud)
或者
AssetManager am = context.getApplicationContext().getAssets();
typeface = Typeface.createFromAsset(am,
String.format(Locale.US, "fonts/%s", "CenturyGothicBold.ttf"));
setTypeface(typeface);Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
672 次 |
| 最近记录: |