在NativeScript中使用VectorDrawable作为图像源

3
我正在尝试在NativeScript中使用Android的VectorDrawable作为Image源。 使用布局检查器,我可以看到有些东西,但没有显示图像。此外,没有关于缺少图像文件的错误,根本没有错误。我无法确定是否可能。非常感谢。
1个回答

2

所以我不知怎么搞定了:

let context = application.android.context;
// vector is VectorDrawable name
        let logo = context.getResources()
            .getIdentifier(this.vector, "drawable", context.getPackageName());
        this.el.nativeElement.android.setBackgroundResource(logo);

        // Access CSS color to change fill color
        let backgroundColor: string = (this.el.nativeElement.backgroundColor)
            ? this.el.nativeElement.backgroundColor.toString()
            : SrcDirective.DEFAULT_COLOR;

        let newBackgroundColor: Color = new Color(backgroundColor);

        this.el.nativeElement.android.getBackground().setTint(newBackgroundColor.android);

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接