Animated loading image in picasso

后端 未结 10 1602
醉酒成梦
醉酒成梦 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条回答
  •  自闭症患者
    2020-11-28 19:44

    @DBragion's answer was great. The problem with it (like many mentioned in the comments) was it didn't provide a way to specify the height / width of the progress indicator. Following is the modified version of his answer with combination of @AkankshaRathod's answer.

    loading_indicator.png

    progress_animation.xml

    
    
    
        
            
        
    
    

    CardView (or any container Layout) containing your ImageView

    
    
        
    
        
    
        
    
    
    

    Picasso loading:

    Picasso.get().load(yourImageURL).into(imgCategoryImage, new Callback() {
        @Override
        public void onSuccess() {
            loadingIndicator.setVisibility(View.GONE);
        }
    
        @Override
        public void onError(Exception e) {
    
        }
    });
    

提交回复
热议问题