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