Having issue on Real Device using vector image in android. SVG-android

我的梦境 提交于 2019-11-27 03:28:01

On newer devices that have hardware rendering turned on by default, you need to explicitly turn on software rendering.

imgView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

I suspect this is probably your problem.

emilpmp

Use AppCompatImageView instead ImageView in xml like the below code

<android.support.v7.widget.AppCompatImageView
    android:tint="#d74313"
    app:srcCompat="@drawable/circle_icon"
    android:layout_width="30sp"
    android:layout_height="30sp" />

and in your build.gradle

android {
  defaultConfig {
    vectorDrawables {
      useSupportLibrary = true
    }
  }
}

If the above doesn't work, try this also in your application class

public class App extends Application {

  @Override public void onCreate() {
    super.onCreate();
    // Make sure we use vector drawables
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
  }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!