1

I am using a ScrollView which contains multiple views one of which is a recycler view. Recycler view contains VectorDrawables which are loaded as soon as the application is run, due to which animations are loaded off-screen, and by the time I scroll down to the recycler view the animations get over.

Currently setting up of AnimatedVectorDrawables is done in onBindViewHolder() of the adapter.

override fun onBindViewHolder(holder: SuccessMetricViewHolder, position: Int) {
    val successMetric = dataList[position]

    with(holder.binding) {
        tvHeading.text = successMetric.count
        tvDescription.text = successMetric.name
    }

    with(holder.binding.ivBannerImage) {
        when (successMetric.name) {
            "Instapreps Location" -> {
                setBackgroundResource(R.drawable.loc_avd_anim)
            }
            "Confidence Diagnosed" -> {
                setBackgroundResource(R.drawable.confi_avd_anim)

            }
            "Questions Solved" -> {
                setBackgroundResource(R.drawable.ques_avd_anim)
            }
            "Play Store Rating" -> {
                setBackgroundResource(R.drawable.stars_avd_anim)
            }
        }
        animatedVectorDrawable = background as AnimatedVectorDrawable
        animatedVectorDrawable.start()
    }
}

I want the VectorDrawables to load when the recycler view is scrolled to and is visible on the screen.

1 Answer 1

0

I can't advise you to use glide/Picasso image loading library. But, maybe using pagination in the RecyclerView which helps to await loading of other views onScroll

This might help

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.