2017-01-12 28 views
2

我试图在NativeScript中使用android的VectorDrawable作为Image源。使用布局检查器,我可以看到有东西但没有显示图像。此外,没有关于丢失图像文件的错误,完全没有错误。VectorDrawable作为NativeScript中的图像源

我找不到它是否可能。

非常感谢。

回答

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);