【问题标题】:textAlign justify property not working in react nativetextAlign justify 属性在本机反应中不起作用
【发布时间】:2019-05-30 21:03:31
【问题描述】:

我尝试在 react native 中使用 textAlign: 'justify' 属性。TextAlign justify 在 Android 上不起作用。 反应原生版本:“react-native”:“0.59.5”

import React from 'react';
import { Image, View } from 'react-native';
import { Text, Button } from 'native-base';
import { connect } from 'react-redux';
import EStyleSheet from 'react-native-extended-stylesheet';
import { colors } from '../styles';

class Login extends React.Component {
  render() {
    return (
        <View style={styles.container}>
            <View style={styles.contentCenter}>
                <Text style={[styles.titleContent,styles.fontBold]}>Simple Secure</Text>
                <Text style={[styles.titleContent,styles.fontBold]}>Reliable Messaging</Text>
            </View>
        </View>
    );
  }
}


const styles = EStyleSheet.create({
    titleContent: {
        color:'#62778c',
        fontSize: '1.4rem',
        textAlign: 'justify',
      }
});

const mapStateToProps = (state) => {
  return {};
};

export default connect(mapStateToProps)(Login);

【问题讨论】:

    标签: react-native text-align


    【解决方案1】:

    查看offical document:

    textAlign: enum('auto', 'left', 'right', 'center', 'justify')

    指定文本对齐方式。值 'justify' 仅在 iOS 上受支持,在 Android 上回退到 left。

    【讨论】:

      【解决方案2】:

      如上所述,android 不支持文本对齐,但您可以通过在 WebView 中添加 html 文本来解决此问题,如下所示:

      <WebView
          source={{ html: "<p style='text-align:justify;'>Your justified text</p>" }}
      />
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-07-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-10-30
        • 2021-12-08
        • 1970-01-01
        相关资源
        最近更新 更多