2017-01-12 2 views
2

Ich versuche, Android VectorDrawable als Image Quelle in NativeScript zu verwenden. Mit Layout-Inspektor kann ich sehen, dass es etwas gibt, aber kein Bild angezeigt wird. Auch gibt es keinen Fehler über fehlende Bilddateien, überhaupt keine Fehler.VectorDrawable als Bildquelle in NativeScript

Ich konnte nicht herausfinden, ob es möglich ist oder nicht.

Vielen Dank im Voraus.

Antwort

2

Also habe ich es irgendwie aus:

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