2017-07-30 3 views
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です。私はdrawableフォルダに画像リソースを持っています。ご覧のとおり、リファレンスはリソースint配列に格納されます。

答えて

0

申し訳ありません。あなたは2つのKenBurnsViewをもう一方の上に重なっていなければならず、あなた自身がクロスフェードを処理します。

関連する問題