Search code examples
androidanimationgridviewpicasso

Animate cell in gridview


I have a gridview and I'm using Picasso library to populate it, I want to add an animation to each cell in the grid to slide in from the bottom, from what I've seen and read the only way to do this is through the Picasso library which it seems only supports .fade is this true, if so I need a new library and glide doesn't support it from what I've seen, is there another approach? Or does anyone know a library I can use that does support this kind of thing?


Solution

  • I would recomment you to do this with Nostra’s Universal Image loader as it comes with function like onLoadingStart() and onLoadingComplete() to set your code

    ImageLoader.getInstance().displayImage(photoUrl, imageView,
                new ImageLoadingListener() {
    
                    @Override
                    public void onLoadingStarted(String arg0, View arg1) {
                        // TODO Auto-generated method stub
                        imageView.setVisibility(View.GONE);
                    }
    
                    @Override
                    public void onLoadingComplete(String arg0, View arg1,
                            Bitmap arg2) {
                        // Here The magic happens , make your ImageView visible and start animation
                        imageView.setVisibility(View.VISIBLE);
                        Animation anim=AnimationUtils.loadAnimation(getApplicationContext(),R.anim.animation);
                        imageView.startAnimation(anim);
                    }
    
                    @Override
                    public void onLoadingFailed(String arg0, View arg1,
                            FailReason arg2) {
                        // Here you can also specify a defferent image from drawable 
    
                    }
    
                    @Override
                    public void onLoadingCancelled(String arg0, View arg1) {
                        imageView.setVisibility(View.GONE);
                    }
                });
    

    The animation is xml animation that has been specified in anim folder inside res folder