React-native 支持 RTL 和 LTR,无需更改设备语言 [英] React-native support RTL and LTR without changing device language

查看:55
本文介绍了React-native 支持 RTL 和 LTR,无需更改设备语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 react-native-i18n 包来支持国际语言.它正在工作,但现在我希望我的应用程序可以根据语言更改应用程序内部的 RTL 和 LTR,而无需更改设备语言.我在我的应用程序中使用了原生基础组件.所以我不能改变他们的样式,如果可能,那么如何?

I have used react-native-i18n package for supporting international language. It is working but now I want my application can change RTL and LTR inside application according to language without changing device language. I used native base components in my application. So I cannot change their styling and If it is possible then How?

我创建了更改语言的设置选项,它正在更改,但如何将应用程序的所有组件的 LTR 更改为 RTL 和 RTL 更改为 LTR.如果有任何解决方案,请告诉我.

I have created settings option to change language and it is changing but how to change LTR to RTL and RTL to LTR all the components of application. If there is any solution please let me know.

推荐答案

来自 react-native 文档:

from the react-native docs:

direction 指定用户界面的方向流.这默认为 inherit,除了 root 节点将有值基于当前语言环境.

direction specifies the directional flow of the user interface. The default is inherit, except for root node which will have value based on the current locale.

这意味着如果您将顶部 View 样式方向更改为 "rtl" 所有子组件都应继承该方向.

this means if you change the top View style direction to "rtl" all child components should inherit the direction.

这篇关于React-native 支持 RTL 和 LTR,无需更改设备语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆