如何将 ActionBar 中的标题文本对齐到右侧而不是默认的左侧?
How to align title text in ActionBar to the right instead of the default left?
我正在使用 NativeScript 创建阿拉伯语 (RTL) 应用程序。我希望操作栏按 rtl 方向排序,因此标题在右边,菜单选项在左边。
我厌倦了使用 css 和 horizontalAlignment,但没有任何效果。
我怎样才能做到这一点?
谢谢。
例子
<Page xmlns="http://schemas.nativescript.org/tns.xsd">
<Page.ActionBar>
<ActionBar >
<Label text="TITLE"/>
</ActionBar>
</Page.ActionBar>
</Page>
并且使用 css 您可以设置右侧或 ActionBar 的其他样式
ActionBar Label{
text-align:right;
horizontal-align:right;
}
如果您因为语言而不是仅仅“对齐”而需要 RTL 支持,我会使用 android.view .View.LAYOUT_DIRECTION_RTL
:
将整个应用程序转换为 RTL
此代码将使应用程序中的 ActionBar(和其他组件)变为 RTL
# app.module.ts
import {
android as Android,
AndroidActivityEventData,
AndroidApplication } from '@nativescript/core/application';
Android.addEventListener(AndroidApplication.activityCreatedEvent, (event: AndroidActivityEventData) => {
event.activity.getWindow().getDecorView().setLayoutDirection(android.view .View.LAYOUT_DIRECTION_RTL);
});
我正在使用 NativeScript 创建阿拉伯语 (RTL) 应用程序。我希望操作栏按 rtl 方向排序,因此标题在右边,菜单选项在左边。
我厌倦了使用 css 和 horizontalAlignment,但没有任何效果。
我怎样才能做到这一点?
谢谢。
例子
<Page xmlns="http://schemas.nativescript.org/tns.xsd">
<Page.ActionBar>
<ActionBar >
<Label text="TITLE"/>
</ActionBar>
</Page.ActionBar>
</Page>
并且使用 css 您可以设置右侧或 ActionBar 的其他样式
ActionBar Label{
text-align:right;
horizontal-align:right;
}
如果您因为语言而不是仅仅“对齐”而需要 RTL 支持,我会使用 android.view .View.LAYOUT_DIRECTION_RTL
:
此代码将使应用程序中的 ActionBar(和其他组件)变为 RTL
# app.module.ts
import {
android as Android,
AndroidActivityEventData,
AndroidApplication } from '@nativescript/core/application';
Android.addEventListener(AndroidApplication.activityCreatedEvent, (event: AndroidActivityEventData) => {
event.activity.getWindow().getDecorView().setLayoutDirection(android.view .View.LAYOUT_DIRECTION_RTL);
});