Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

justify align for rtl text on react-native

Tags:

react-native

How could I align the RTL text to justify on react-native? As the react-native website says we could set align of text to 'auto', 'left', 'right', 'center', 'justify' but the justify one is not working on RTL text.

like image 701
jsina Avatar asked Sep 23 '17 19:09

jsina


People also ask

How do you align text justify in react native?

Infinitbility React Native Here you will get textAlign justify example and if not working then alternative solution. React Native provide textAlign style to make to make text justify but it's works in iOS, and android 8.0 ( Oreo ) or above (API level >= 26). The value will fallback to left on lower Android versions.

How do you align text left and right on same line in react native?

textAlign props left: Used to align the text component to the left-hand side. right: align text to the right-hand side (make sure to add flex: 1). center: It align text component to the center (make sure to add flex: 1). auto: It align text automatically.

How do I align text to the left in react native?

textAlign Props textAlign use for align text in react native like left, right, etc. Specifies text alignment. On Android, the value 'justify' is only supported on Oreo (8.0) or above (API level >= 26). The value will fallback to left on lower Android versions.


1 Answers

text justify not support in react native android native. but there is a trick that you justify your text with WebView Component...

here is a sample code:

 <WebView
      source={{
        html:
          "<style>p{text-align:justify}</style>" +
          "<p>" +
          "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus commodo tortor ut ipsum pharetra sodales. Praesent sed diam non lacus convallis dapibus. Sed vulputate erat risus, ac hendrerit eros egestas id. Etiam pellentesque auctor ipsum, non cursus nisi gravida sed. Ut eget pretium risus. Curabitur a lectus odio. Etiam felis urna, pharetra ut odio in, tristique suscipit tortor. Cras vitae risus odio. Etiam a leo elit. Duis molestie fermentum mi vitae pretium. Morbi luctus semper quam, et suscipit nisi convallis dictum. Fusce sit amet est dapibus, interdum ante non, lacinia metus. Donec at nulla non ante consectetur vulputate. Cras tristique porttitor ligula quis posuere. Integer nec laoreet felis, at tempor leo. Ut et convallis quam." +
          "</p>"
      }}
    />

if you want call your body texts from your server compile to html and use your source in it (this is not a good but only way)

like image 154
Hamed Keshavarz M Avatar answered Nov 15 '22 09:11

Hamed Keshavarz M