react-native关于Text组件在android部分真机上显示不全问题


解决方案:

1. 文字末尾添加空格

Example: {empIDText + ' '}

before it was like: {empIDText}

2. 设置text组件的fontFamily

<Text style={{fontFamily: ""}}>

3. 设置text组件的textBreakStrategy

有关textBreakStrategy的('simple', 'highQuality', 'balanced')的不同之处,可以参考stack overflow上的问题:https://stackoverflow.com/questions/53236569/what-is-the-difference-between-simple-highquality-balanced-for-textbreakstrate

<Text key={node.key} textBreakStrategy="simple">{node.content}</Text>

4.全局设置text组件的fontFamily

import React, {component} from 'react'
import {View, Platform, Text} from 'react-native';

const defaultFontFamily = {
      ...PlatForm.select({
            android: {fontFamily: ' '}
    })          
}

const oldRender = Text.render;
Text.render = function(...args) {
    const origin = oldRender.call(this, ...args);
    return React.cloneElement(origin, {
         style: [defaultFontFamily, origin.props.style]
   });
};


  转摘:https://segmentfault.com/a/1190000023622085


					


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM