【发布时间】:2017-01-12 12:29:47
【问题描述】:
我正在尝试在 NativeScript 中使用 android 的 VectorDrawable 作为 Image 源。使用布局检查器,我可以看到有东西但没有显示图像。也没有关于丢失图像文件的错误,完全没有错误。
我不知道这是否可能。
非常感谢。
【问题讨论】:
标签: android nativescript android-vectordrawable
我正在尝试在 NativeScript 中使用 android 的 VectorDrawable 作为 Image 源。使用布局检查器,我可以看到有东西但没有显示图像。也没有关于丢失图像文件的错误,完全没有错误。
我不知道这是否可能。
非常感谢。
【问题讨论】:
标签: android nativescript android-vectordrawable
所以我想通了:
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);
【讨论】: