Animated loading image in picasso

后端 未结 10 1622
醉酒成梦
醉酒成梦 2020-11-28 19:10

I have the following code to load an image in Picasso, using a drawable for the placeholder to display while the image is downloading. What I want though is an animated spin

10条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 19:24

    I found answer to this question!

    See: https://github.com/square/picasso/issues/427#issuecomment-266276253

    In addition to answer of @DBragion, try below.

    Now we can fix height and width!

    image_view.scaleType = ImageView.ScaleType.CENTER_INSIDE
    
    picasso.load(your_path)
            .fit()
            .centerCrop()
            .noFade()
            .placeholder(R.drawable. progress_animation)
            .into(image_view)
    

    I think there are two key points.

    1. use noFade()

    2. set image_view's scaleType to "CENTER_INSIDE"

提交回复
热议问题