ReactNative 不同大小Text文本底部對(duì)齊

需求

顯示金額時(shí),小數(shù)部分字體要小,整數(shù)部分字體要大。底部肯定是要對(duì)齊的,如下圖

different-text-align-bottom

實(shí)現(xiàn)方法

<View style={styles.con}>
  <Text style={[styles.big]}>
    {v1}
    <Text style={[styles.small]}>{v2}</Text>
  </Text>
</View>

// 樣式
const styles = StyleSheet.create({
  con: {
    flexDirection: 'row',
    justifyContent: 'flex-end',
    alignItems: 'flex-end',
  },
  big: {
    includeFontPadding: false,
    fontSize: 16,
  },
  small: {
    includeFontPadding: false,
    fontSize: 14,
  },
});

參考:

https://stackoverflow.com/questions/50467856/nested-text-vertical-align-not-working-react-native

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容