简体   繁体   English

导航按钮在Nativescript / Angular中的远程图像

[英]Remote image on NavigationButton in Nativescript/Angular

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. 它在IOS中工作正常,但在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>

but I get an error during compilation. 但是在编译过程中出现错误。 The custom image is a remote image ( https://myimage ), but android is looking into local file resources. 自定义图像是一个远程图像( https:// myimage ),但是android正在调查本地文件资源。

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 我也尝试使用代替,但是同样的问题

You can try removing the <NavigationButton> for android and putting the <StackLayout> directly inside your <ActionBar> with a horizontalAlignment set to 'left' 您可以尝试删除Android的<NavigationButton>并将<StackLayout>直接放置在<ActionBar>内部,并将horizontalAlignment设置为'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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM