React-native textAlign justify

Android

I tried to use textAlign to make the text justified, but it doesn't work.

<Text style={{textAlign: 'justify',color:'#1B3D6C', margin: 20}}>
Lorem ipsum dolor sit amet, et usu congue vocibus, ei sea alienum repudiandae, intellegam quaerendum an nam. Vocibus apeirian no vis, eos cu conguemoo scaevola accusamus. Et sea placerat persecutii oinn
</Text>

      

enter image description here

Edit: Ok, textAlign justify doesn't work on Android, so now I'm asking if there is some kind of solution for this? I really need!

+11


source to share


2 answers


Android does not support text alignment. The React Native Text component docs about the style attribute state:

textAlign enum ('auto', 'left', 'right', 'center', 'justify'): Determines the alignment of the text. The 'justify' value is only supported on iOS and deviations on Android .



You can work around this limitation by using the React Native WebView component . The content of the WebView can be HTML aligned text. Like this:

<View style={{flex: 1}}>
    <WebView
        source={{ html: "<p style='text-align: justify;'>Justified text here</p>" }}
    />
</View>

      

+14


source


UPDATE

For older versions, responsive system textAlign:'justify'

didn't work for Android, but now it supports textAlign:'justify'

Android Oreo and above.

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



Determines the alignment of the text. The justify value is only supported on iOS and Android Oreo (8.0) or higher (API level> = 26) . For a lower Android version, this will fall back to the left.

Read the updated docs here

0


source







All Articles