0

我在我的应用程序的登录屏幕中使用 KenBurnsView 在后台显示几张图像。问题是这些图像变化太突然了。在将转换从一个图像更改为另一个图像时,不是一种实现淡入/淡出效果的方法,挂钩视图 API 中的某个位置吗?

这是我用来实现转换的代码。

private void setupAnimationBackground() {
    mBackgroundImageView.setTransitionListener(new KenBurnsView.TransitionListener() {
        @DrawableRes int[] mResources = new int[]{
                R.drawable.splash1, R.drawable.splash2, R.drawable.splash3,
                R.drawable.splash4, R.drawable.splash5, R.drawable.splash6
        };

        int mIndex = 0;

        @Override
        public void onTransitionStart(Transition transition) {
            mIndex = (mIndex == mResources.length - 1) ? 0 : mIndex + 1;
        }

        @Override
        public void onTransitionEnd(Transition transition) {
            mBackgroundImageView.setImageDrawable(ContextCompat.getDrawable(getContext(), mResources[mIndex]));
        }
    });
}

mBackgroundImageView 是一个 KenBurnsView。我的可绘制文件夹中有图像资源。如您所见,我将引用存储在资源 int 数组中。

4

1 回答 1

0

对不起,没有。您需要有两个 KenBurnsViews 一个重叠在另一个之上,然后您自己处理交叉淡入淡出。

于 2017-12-08T21:27:03.343 回答