I am using Android Studio to convert my SVG image to XML file . It works fine when I try to access it using R.drawable.svgimage but now I need to decode that image to bitmap.
I tried the following. It returns null for the bitmap.
mResId = R.drawable.svgimage
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bitmap = BitmapFactory.decodeResource(
mContext.getResources(), mResId, options);
The following code will works perfectly I have used it: Here
R.drawable.ic_airport
is my svg image stored in drawable folder.try this,
You can use this library SVG Android and use it this way:
After that, convert the SVG into a Drawable:
and then, the drawable into a bitmap: