将大小设置为 Android 上 NavigationButton 中的图标
Set size to icon in NavigationButton on Android
在 Nativescript/Angular 应用程序中,我在 header 的左侧显示了用户的头像。对于 Android,我必须使用 NavigationButton:
<NavigationButton #navigationButton *ngIf="isAndroid" [loaded]="navigationButtonLoaded()" [icon]="customImage" (tap)="toggleSideDrawer()">
</NavigationButton>
自定义图片为https资源; NavigationButton 需要本地资源,所以当用户登录时,我使用本地资源下载图像。它有效,但图像很大,所以它填满了整个 header。我试图简单地添加一个 class con NavigationButton 设置宽度和高度,但它不起作用。所以我添加了加载函数,我尝试手动设置它,它没有给出任何错误但它不起作用:
....
@ViewChild('navigationButton') navigationButton: NavigationButton;
....
navigationButtonLoaded() {
if (this.navigationButton) {
this.navigationButton.effectiveWidth = 45;
this.navigationButton.effectiveMinWidth = 45;
this.navigationButton.effectiveHeight = 45;
this.navigationButton.effectiveMinHeight = 45;
}
}
我认为单独调整 NavigationButton 的大小是不可能的。您必须使用 Custom Title View,放置一个图像并将其在左侧对齐以模仿 NavigationButton。
在 Nativescript/Angular 应用程序中,我在 header 的左侧显示了用户的头像。对于 Android,我必须使用 NavigationButton:
<NavigationButton #navigationButton *ngIf="isAndroid" [loaded]="navigationButtonLoaded()" [icon]="customImage" (tap)="toggleSideDrawer()">
</NavigationButton>
自定义图片为https资源; NavigationButton 需要本地资源,所以当用户登录时,我使用本地资源下载图像。它有效,但图像很大,所以它填满了整个 header。我试图简单地添加一个 class con NavigationButton 设置宽度和高度,但它不起作用。所以我添加了加载函数,我尝试手动设置它,它没有给出任何错误但它不起作用:
....
@ViewChild('navigationButton') navigationButton: NavigationButton;
....
navigationButtonLoaded() {
if (this.navigationButton) {
this.navigationButton.effectiveWidth = 45;
this.navigationButton.effectiveMinWidth = 45;
this.navigationButton.effectiveHeight = 45;
this.navigationButton.effectiveMinHeight = 45;
}
}
我认为单独调整 NavigationButton 的大小是不可能的。您必须使用 Custom Title View,放置一个图像并将其在左侧对齐以模仿 NavigationButton。