NativeScript RTL support

假装没事ソ 提交于 2020-12-12 01:48:26

问题


My app can have only one language, and it should be aligned RTL. Currently when I run my app with tns preview the ActionBar labels appears in the left (instead of the right) and so on with any other widget.

I have found some localization plugins but not sure I need them for my case - since I have only one language and text direction.

I have been through all GitHub issues related to RTL but I'm still not sure how to work it out. Any idea how I can force my app and change the layout for RTL language?


回答1:


You may set the layout direction to RTL at runtime, this would not only update ActionBar but any layout in app will be forced for RTL.

import * as app from 'tns-core-modules/application';

app.android.addEventListener(app.AndroidApplication.activityCreatedEvent, (event: app.AndroidActivityEventData) => {
   event.activity.getWindow().getDecorView().setLayoutDirection(android.view.View.LAYOUT_DIRECTION_RTL);
});

Playground Sample



来源:https://stackoverflow.com/questions/55096138/nativescript-rtl-support

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!