简体   繁体   中英

React-Native ToolbarAndroid does not support fontFamily

I have custom fonts working in my project using React Native's in-built support for cross-platform custom fonts. I'm curious if there is anyway to apply fontFamily to the ToolbarAndroid component ( https://facebook.github.io/react-native/docs/toolbarandroid.html ). Unfortunately, the toolbar style does not support the key.

I also attempted setting title to a component myTitle and feeding it to the toolbars title attribute, but this results in a cyclic error:

var myTitle = <Text style={{fontFamily: 'MyFont'}}>My Profile</Text>

Ideally, I would love to keep the native toolbar rather than replace it with a custom JS toolbar that supports custom fonts.

Fixed by placing the mytitle component, using custom fontFamily , within the ToolbarAndroid tags like so:

<ToolbarAndroid>{mytitle}</ToolbarAndroid>

Rather than trying to place the component within the title attribute of ToolbarAndroid.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM