reactjs - 反应原生纸张组件没有拉出正确的字体
问题描述
我的react-native-paper
组件textInput
不会拉出我设置的字体。
<View style={styles.inputCon}>
<TextInput
multiline={true}
label="Ime aktivnosti"
mode="outlined"
value={ime}
onChangeText={(value) => {
setIme(value);
}}
/>
</View>
我遵循了有关如何更改 RN Paper 组件的字体的官方文档https://callstack.github.io/react-native-paper/fonts.html
const fontConfig = {
default: {
regular:{
fontFamily: "Poppins_400Regular",
fontWeight:'normal'
},
medium: {
fontFamily: "Poppins_500Medium",
fontWeight:'normal'
},
light: {
fontFamily: "Poppins_300Light",
fontWeight:'normal'
},
thin: {
fontFamily: "Poppins_200ExtraLight",
fontWeight:'normal'
},
bold: {
fontFamily: "Poppins_700Bold",
fontWeight:'normal'
}
},
};
const theme = {
...DefaultTheme,
fonts: configureFonts(fontConfig),
};
另一个组件,也来自react native paper
正确拉字体
<Searchbar
placeholder="Type here..."
onChangeText={text => this.searchItems(text)}
value={this.state.value}
/>
解决方案
import { configureFonts, DefaultTheme, Provider as PaperProvider } from 'react-native-paper';
const theme = {
...DefaultTheme,
fontFamily: {...DefaultTheme.fonts.regular.fontFamily = 'fontName'}
};
export default class App extends Component {
render() {
const RootStack = createStackNavigator();
return (
<PaperProvider theme={theme}>
<SafeAreaProvider>
</SafeAreaProvider>
</PaperProvider>
);
}
反应原生 cli:2.0.1 反应原生:0.63.4
推荐阅读
- eclipse - Jfoenix 9 和 fontawesome
- azure-devops - Azure 管道参数作为秘密变量
- linux - 如何在 L 和 R 上同时分离 L 和 R 通道以输出 2 个不同的音频源(节目)?
- javascript - 使用 Angular 的密码确认表
- powershell - 无法使用 new-getfirewallrule 将防火墙规则添加到本地 GPO
- .net - 动态识别日志中的错误频率
- angular - 获取错误 cx-storefront is not known element Spartacus Angular storefront in SAP Hybris
- node.js - 在实时通话期间修改 Twilio statusCallback
- javascript - 将状态值设置为单击按钮的值
- java - #姓名!通过 apache POI 将用户定义的“SpellNumber”函数设置为 excel 单元格时出错