【问题标题】:VectorDrawable as Image source in NativeScriptVectorDrawable 作为 NativeScript 中的图像源
【发布时间】:2017-01-12 12:29:47
【问题描述】:

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

我不知道这是否可能。

非常感谢。

【问题讨论】:

    标签: android nativescript android-vectordrawable


    【解决方案1】:

    所以我想通了:

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

    【讨论】:

      猜你喜欢
      • 2016-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多