ImageSwitcher没有显示出来 [英] ImageSwitcher is not showing outAnimation

查看:254
本文介绍了ImageSwitcher没有显示出来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用android的ImageSwitcher小部件在2张图像之间进行切换,例如幻灯播放,但它仅以动画形式显示,而没有以动画形式显示.有什么问题吗?

I'm using ImageSwitcher widget of android to transition between 2 images like a slide show but it is showing only in animation and out animation is not showing. What is the issue?

代码:

 imageSwitcher.setFactory(new ViewSwitcher.ViewFactory() {
                    @Override
                    public View makeView() {

                        RoundedImageView imageView = new RoundedImageView(context);
                        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
                        imageView.setLayoutParams(new
                                ImageSwitcher.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT));
                        imageView.setCornerRadius(context.getResources().getDimension(R.dimen.border_radius));

                        return imageView;
                    }
                });


Animation in,out;
in = AnimationUtils.loadAnimation(context, R.anim.bottom_in);
out = AnimationUtils.loadAnimation(context, R.anim.top_out);

 imageSwitcher.setInAnimation(in);
            imageSwitcher.setOutAnimation(out);

            Glide.with(context)
                    .asDrawable()
                    .load(url)
                    .thumbnail(.1f)
                    .apply(requestOptions)
                    .into(new SimpleTarget<Drawable>() {
                        @Override
                        public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {

                            imageSwitcher.setImageDrawable(resource);
                        }
                    });

top_out动画:

top_out animation:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="300"
    android:fromYDelta="0%"
    android:interpolator="@android:anim/decelerate_interpolator"
    android:toYDelta="-100%" />

bottom_in动画:

bottom_in animation:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="300"
    android:fromYDelta="100%"
    android:interpolator="@android:anim/decelerate_interpolator"
    android:toYDelta="0%" />

推荐答案

我能够通过从Glide请求中删除".thumbnail(.1f)"来解决此问题.不了解更深的景象,但ImageSwitcher现在对我来说很好. 感谢那些以任何方式提供帮助的人.

I was able to resolve the issue by removing '.thumbnail(.1f)' from the Glide request. Don't know the deeper sight but ImageSwitcher is working fine for me now. Thanks to fellows who helped by any means.

这篇关于ImageSwitcher没有显示出来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆