3

I'm working on a right-to-left react native app and want to handle layout with direction: 'rtl' or direction: 'rtl'.

It works fine with ios but it doesn't work on Android for no reason.

An example code is :

<View style={{flexDirection: 'row', justifyContent: 'space-between', direction: 'rtl'}}>
  <Text>
    right content
   </Text>
   <Text>
    left content
   </Text>
</View>

Thanks.

1 Answer 1

7

Direction props is only for iOs. Refer documentation https://facebook.github.io/react-native/docs/layout-props.html#direction

If you want to layout your views from right to left then below code would work.

<View style={{justifyContent: 'space-between',flexDirection: 'row-reverse'}}>
    <Text> text1  </Text>
    <Text> text2  </Text>
    <Text> text3  </Text>
    <Text> text4  </Text>
    <Text> text5  </Text>
  </View>
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks .. but what's an alternative solution for android ?
Apparently we can use flexDirection: 'row-reverse' instead Please update your answer to include the alternative solution as well
Sorry, i did not add complete code in my previous answer. I added new one with code as well.
You can just use flexDirection: I18nManager.isRTL ? "row-reverse" : "row"
github.com/facebook/react-native/issues/17361 also try the "prefixing all the text RTL with \u200F"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.