sharedElement transition gif错误-如何解决?

时间:2018-10-23 06:46:44

标签: android transition gif

我正在尝试进行android sharedElement转换,以通过Glide扫描在线图像,而图像是gif,并且图像显示在viewPager中。我发现当imageView执行sharedElement转换时,单击ImageView只会显示第一帧。我的项目中的以下代码。

Glide.with(context)
                .load(imageUrl)
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .listener(new RequestListener<String, GlideDrawable>() {
                    @Override
                    public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
                        return false;
                    }

                    @Override
                    public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                        if (imageView == null) {
                            return false;
                        }
                        if (imageView.getScaleType() != ImageView.ScaleType.FIT_XY) {
                            imageView.setScaleType(ImageView.ScaleType.FIT_XY);
                        }
                        ViewGroup.LayoutParams params = imageView.getLayoutParams();
                        int vw = imageView.windowW;
                        float scale = (float) vw / resource.getIntrinsicWidth();
                        final int vh = (int) ((float) resource.getIntrinsicHeight() * scale);
                        params.height = vh + imageView.getPaddingTop() + imageView.getPaddingBottom();
                        imageView.setLayoutParams(params);
                        imageView.setVH(vh);
                        return false;
                    }
                })
                .into(imageView);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            setEnterSharedElementCallback(new SharedElementCallback() {
                @Override
                public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
                    sharedElements.clear();
                    View view = mViewPager.getAdapter().getItem(mViewPager.getCurrentItem()).getImg();
                    sharedElements.put(ViewCompat.getTransitionName(view), view);
                }
            });
        }

0 个答案:

没有答案