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數組中。