atl*_*teh 25 android right-to-left react-native
本机作出反应的新版本已经发布了RTL设备的支持:
https://facebook.github.io/react-native/blog/2016/08/19/right-to-left-support-for-react-native-apps .html
然而,似乎在RTL安卓设备中,RTL布局是强制的,并且没有办法改变它,所以现在所有的应用程序都被破坏了RTL设备.如何强制我的应用程序使用LTR?
atl*_*teh 42
我设法通过添加到MainApplication.java以下内容来解决此问题
import com.facebook.react.modules.i18nmanager.I18nUtil;
public class MainApplication extends Application implements ReactApplication {
@Override
public void onCreate() {
super.onCreate();
// FORCE LTR
I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
sharedI18nUtilInstance.allowRTL(getApplicationContext(), false);
....
}
}
Run Code Online (Sandbox Code Playgroud)
在manifest.xml文件中添加android:supportsRtl="false"到您的应用程序标记
如果您使用的是世博会
import { I18nManager} from 'react-native';
I18nManager.allowRTL(false);
export default class <className> extends Component {
}
Run Code Online (Sandbox Code Playgroud)
只需在项目入口点添加这些代码行即可,例如App.tsx
import { I18nManager } from "react-native";
// disable RTL
try {
I18nManager.allowRTL(false);
I18nManager.forceRTL(false);
// the next line is the most effective one
I18nManager.swapLeftAndRightInRTL(false);
} catch (e) {
console.log(e);
}
Run Code Online (Sandbox Code Playgroud)
克服“现在”的当前情况,因为即使使用这些设置,rtl 仍然是强制的!
你必须改变每flexDirection: "row"一个
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4833 次 |
| 最近记录: |