Hi,
I am trying to load an SVG from web using Glide (Kotlin), below is the gradle file
dependencies {
implementation 'com.github.bumptech.glide:glide:4.5.0'
kapt 'com.github.bumptech.glide:compiler:4.5.0'
}
I am using Generated API, I am able to get GlideApp but I am not sure how to get SvgSoftwareLayerSetter? do i need import those java files separately? wont things work out of the box with GlideApp?
GlideApp.with(this)
.`as`(PictureDrawable::class.java)
.placeholder(R.drawable.image_loading)
.error(R.drawable.image_error)
.transition(withCrossFade())
.listener(SvgSoftwareLayerSetter()) <---- Getting unresolved symbol error here
Those files are from a sample app, they're not provided by the main library. The sample app is here: https://github.com/bumptech/glide/tree/master/samples/svg. Glide doesn't officially support SVG.
Hi,
The sample app do display svg right? I have seen that the file is from the sample app, that's how I know SvgSoftwareLayerSetter exists......what I was trying to do was to implement this in Kotlin, and wanted to know whether all those Svg java classes are a must requirement and need to be imported to Kotlin.
Ah @TWiStErRob might be able to comment better. I'm not sure if the SVG software layer setter is still a requirement, it probably is?
It's not a necessity to use those classes if you implement the functionality in a different way. e.g. you can set the software layer in layout XML. You can try hardware accelerated SVG rendering, but it probably won't work, see class comment. I haven't checked the latest library version though.
Decoder/transcoder/module is the recommended way though, it separates the tasks and fits SVG into Glide request flow.
I am not trying to do anything heavy here :-), my aim is to load an svg from API and set it to an imageview.
sample: https://restcountries.eu/data/dza.svg , I don't want alter or customize the rendering of SVG and all, I was trying to follow the svg sample and was stuck at the listener part.
Just replicate the sample, coping over classes from that folder as necessary. Let us know if you're still having problems.
@anoop4real Same here, how did you solved?
@bernardomesk
I didnt try further, I ended up in using AndroidSvgLoader
It was really simple
implementation 'com.github.ar-android:AndroidSvgLoader:1.0.1'
That library did exactly as I said above, copied the sample code and made it a reusable function.
Hope the below code is useful for you.
Add this dependency in build.gradle
implementation 'com.github.corouteam:GlideToVectorYou:v2.0.0'
Now start working in MainActivity.java
ImageView image = (ImageView) findViewById(R.id.ivimage);
String url= https://your_url/banking.svg GlideToVectorYou.init().with(this).load(Uri.parse(url),image);