Is it possible to pull Android and write?

Asked 2 years ago, Updated 2 years ago, 40 views

You know, there's a refresh function when you pull from the Android recycling view

But when I pull, I want to write or work on something else

Is there a way to change the image that comes out when you pull it?(Only the round refresh icon always comes out)

Thank you

android

2022-09-22 08:45

1 Answers

SwipeRefreshLayout implements a scroll operation by implementing NestedScrollingParent and NestedScrollingChild, and the circle view that appears during swiping is set to CirclementCircleview.

Depending on the scroll value, it can be seen as a structure that handles the visible state change and scale operation of CircleImageView and the rotation operation of CircleProgressDrawable.

I'm not sure exactly what action you want to implement when you pull, but if you're curious about how to change only the image, you can do it as follows.

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        for (i in 0 until swipeLayout.childCount) {
            val child = swipeLayout.getChildAt(i)
            if (child::class.java.simpleName == "CircleImageView") {
                (child as ImageView).apply {
                    Remove setImageDrawable(null) //CircleProgressDrawable
                    Remove background = null //circle background
                    setImageResource(R.mipmap.ic_launcher) //Any icon settings
                }
                break
            }
        }
    }


2022-09-22 08:45

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.