问题
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