Android Glide library not working with shared element transitions

前端 未结 2 433
青春惊慌失措
青春惊慌失措 2020-12-06 17:38

I\'m looking to adopt the Glide library in place of Universal Image Loader but I\'m running into a problem with regards to shared element transitions.

In my simple S

2条回答
  •  太阳男子
    2020-12-06 18:01

    I tried your code and got the same result, then I tried another implementation following this: https://github.com/codepath/android_guides/wiki/Shared-Element-Activity-Transition

    And made some changes, which I think are the key here:

    The centerCrop should be set on the ImageView, if we set it with Glide it causes the same bug. activity_main.xml

        
    

    BaseActivity.java On the MainActivity dontTransform should be true and on DifferentActivity false.

        public void displayImageGlide(String url, ImageView imageView, Boolean dontTransform) {
        if (dontTransform) {
            Glide.with(this).load(url)
                    .skipMemoryCache(true)
                    .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                    .dontTransform()
                    .into(imageView);
            return;
        }
    
            Glide.with(this).load(url)
                    .skipMemoryCache(true)
                    .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                    .into(imageView);
       }
    

    Edit, see how it looks: https://www.dropbox.com/s/30s5l8awxogltls/device-2015-06-23-153153.mp4?dl=0

提交回复
热议问题