Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-native textAlign justify

Tags:

react-native

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 doesnt work on Android , so what im asking now if there is some solution to this? I really need!

like image 279
Brunaine Avatar asked Sep 04 '25 03:09

Brunaine


1 Answers

Android does not support text justification. The docs of React Native Text component about the style attribute says:

textAlign enum('auto', 'left', 'right', 'center', 'justify') : Specifies text alignment. The value 'justify' is only supported on iOS and fallbacks to left on Android.

A workaround for this limitation is to use a React Native WebView component. The content of the WebView can be an HTML code with the justified text. Like this:

<View style={{flex: 1}}>
    <WebView
        source={{ html: "<p style='text-align: justify;'>Justified text here</p>" }}
    />
</View>
like image 108
Bruno Peres Avatar answered Sep 06 '25 04:09

Bruno Peres