kotlin – Android glide SliderLayout images from url getting cropped-ThrowExceptions

Exception or error:

Following is the initialisation code for slider layout.

        val requestOptions = RequestOptions()
    requestOptions.fitCenter()
    for (i in 0 until bannerListArray.size()) {
        val sliderView = TextSliderView(this)

        var bannerListArrayObj = bannerListArray.get(i).asJsonObject
        sliderView.image(bannerListArrayObj.get("bannerimage").asString)
        sliderView.description(bannerListArrayObj.get("bannertitle").asString)
        sliderView.setRequestOption(requestOptions)
        sliderView.setProgressBarVisible(true)
        sliderView.setOnSliderClickListener(this)
        sliderView.bundle(Bundle())
        sliderView.bundle.putString("extra", bannerListArrayObj.get("bannertitle").asString)
        mDemoSlider!!.addSlider(sliderView)
    }

    // set Slider Transition Animation
    mDemoSlider!!.setPresetTransformer(SliderLayout.Transformer.Accordion)
    mDemoSlider!!.setCustomIndicator(custom_indicator)
    mDemoSlider!!.setCustomAnimation(DescriptionAnimation())
    mDemoSlider!!.setDuration(4000)
    mDemoSlider!!.addOnPageChangeListener(this)
    mDemoSlider!!.stopCyclingWhenTouch(false)

    if(bannerListArray.size()==0){
        mDemoSlider!!.stopAutoCycle()
    }else{
        mDemoSlider!!.startAutoCycle()
    }

Images getting cropped while executing the function. But url contains full size image in browser. How to resolve it? Is there any scaleType for this Glider slider?

Update : Found out requestOptions.fitCenter() is the term i have to modify. But fitXY is not available from glide library version 4+. How to override it? Or is there any alternate method to use fitXY

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *