Nativescript/Angular 导航按钮上的远程图像 [英] Remote image on NavigationButton in Nativescript/Angular
问题描述
我想将用户的头像放在我的应用标题的左侧.在 IOS 中可以正常工作,但在 android 中不起作用.我试图这样做:
I want to put the user's avatar on the left of my app's header. It works fine in IOS, but it doesn't work in android. I tried to do this:
<NavigationButton [icon]="customImage" color="#a81b38" (tap)="toggleSideDrawer()" *ngIf="isAndroid">
<StackLayout verticalAlignment="center">
<Label id="avatarImg" height="45" width="45" borderRadius="50" backgroundColor="#eeeeee"></Label>
</StackLayout>
</NavigationButton>
但是我在编译过程中遇到错误.自定义图像是远程图像(https://myimage),但 android 正在查看本地文件资源.
but I get an error during compilation. The custom image is a remote image (https://myimage), but android is looking into local file resources.
所以我删除了图标并将图像放入其中,尝试这样做:
So I removed the icon and I put the image inside, trying this:
<NavigationButton color="#a81b38" (tap)="toggleSideDrawer()" *ngIf="isAndroid">
<StackLayout verticalAlignment="center">
<Label [style.background-image]="customImage" style.background-position="center"
style.background-size="cover" class="avatarImage" height="30" width="30" borderRadius="50"
backgroundColor="#eeeeee"></Label>
</StackLayout>
</NavigationButton>
我没有收到任何错误,但我在标题中看不到任何内容,全是白色的.我也尝试使用代替,但同样的问题
I don't get any error, but I can't see anything in my header, it's all white. I tried also to use instead of , but same issue
推荐答案
你可以尝试去掉android的
,直接把
在您的
中,将 horizontalAlignment
设置为left"
You can try removing the <NavigationButton>
for android and putting the <StackLayout>
directly inside your <ActionBar>
with a horizontalAlignment
set to 'left'
<ActionBar>
<StackLayout *ngIf="isAndroid" horizontalAlignment="left" verticalAlignment="center">
<Label [style.background-image]="customImage" style.background-position="center"
style.background-size="cover" class="avatarImage" height="30" width="30" borderRadius="50"
backgroundColor="#eeeeee"></Label>
</StackLayout>
</ActionBar>
这篇关于Nativescript/Angular 导航按钮上的远程图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!