[英]How do I center ActionBar title text in Android (with Nativescript)?
我想居中对齐操作栏文本
<ActionBar class="text-center" [title]="title" (loaded)="onLoadedActionBar()"></ActionBar>
在 NativeScript 中。 目前,上面呈现的标题左对齐。 我尝试添加一个类并添加text-align: center;
但这没有用。 在 iOS 中,它似乎根据 NativeScript 文档中的图像自动对齐此文本中心。
万一其他人需要它的解决方案:不要使用 ActionBar 标记的 title 属性,而是使用 Label 作为单独的内部标记,如下所示:
<ActionBar (loaded)="onLoadedActionBar()">
<Label class="title" [text]="title"></Label>
</ActionBar>
并在 css 中设置标题样式:
.title {
font-weight: bold;
font-size: 17px;
}
为我解决了。
解决方案
为了更清楚地指出这一点,我在这个答案中写了 Meggan Naude 的解决方案。 在问题提要中回答您自己的问题还不够明显。
不使用ActionBar
标签的title
属性,而是使用Label
作为单独的内部标签,如下所示:
<ActionBar (loaded)="onLoadedActionBar()">
<Label class="title" [text]="title"></Label>
</ActionBar>
并在css
设置标题样式:
.title {
font-weight: bold;
font-size: 17px;
}
同样,这个答案归功于提问者本身。 干杯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.