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

后端 未结 2 1217
甜味超标
甜味超标 2020-11-29 23:57

I use svg-android.jar from https://github.com/pents90/svg-android at its work fine but only on emulator devices in eclipse. Agrrrr. On real devices

相关标签:
2条回答
  • 2020-11-30 00:39

    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);
      }
    }
    
    0 讨论(0)
  • 2020-11-30 00:50

    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.

    0 讨论(0)
提交回复
热议问题