首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ImageSwitcher未显示outAnimation

ImageSwitcher未显示outAnimation
EN

Stack Overflow用户
提问于 2018-09-16 00:09:25
回答 2查看 84关注 0票数 0

我正在使用安卓的ImageSwitcher小工具在2个图像之间切换,就像幻灯片一样,但它只在动画中显示,而输出动画不显示。问题出在哪里?

代码:

代码语言:javascript
复制
 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动画:

代码语言:javascript
复制
<?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动画:

代码语言:javascript
复制
<?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%" />
EN

回答 2

Stack Overflow用户

发布于 2018-09-16 01:05:38

在代码中未发现问题可能是top_out动画中存在问题

代码语言:javascript
复制
<?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%" />

在android中:toYDelta

代码语言:javascript
复制
change it android:toYDelta="-100%" to android:toYDelta="100%"
票数 0
EN

Stack Overflow用户

发布于 2018-09-16 01:14:10

我能够通过从Glide请求中删除'.thumbnail(.1f)‘来解决这个问题。不知道更深层次的问题,但ImageSwitcher现在对我来说工作得很好。感谢那些尽一切所能提供帮助的人。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52346477

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档