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 it just empty imageView
on screen.
here is my code:
SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.test);
Drawable drawable = svg.createPictureDrawable();
imgView.setImageDrawable(drawable);
any suggestion?
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.
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);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With