2016-08-30 18 views
0

2枚の画像を持ったスプラッシュスクリーンを作ろうとしています.1枚目が中央で上に移動し、2枚目が1枚目に完全に登場します。 私は第1の画像についてアニメーションを行ったが、第2の画像は所望の方法では動作していない。実際に私はimageswitcherやその他の機能を使っているのかどうかはわかりません。どうすればいいのか教えてください。 ここでコードを共有します。相対レイアウトで画像ビュー移動

public class Splash_screen extends Activity { // SPLASH ACTIVITY 

     @Override 

     protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.splash_screen); 

      ImageView kfcpic = (ImageView) findViewById(R.id.kfclogo); 
      ImageView sogood= (ImageView)findViewById(R.id.sogood); 


      TranslateAnimation animation = new TranslateAnimation(0,0,0,-500); // new TranslateAnimation(xFrom,xTo, yFrom,yTo) 
      animation.setDuration(3000); // animation duration 
      //animation.setRepeatCount(0); // animation repeat count 
      animation.setRepeatMode(1); 
      animation.setFillAfter(true); 
      // repeat animation (left to right, right to left) 
      //animation.setFillAfter(true); 

      kfcpic.startAnimation(animation); // start animation 


     Thread logoTimer = new Thread() { 
      public void run() { 
       try { 
        sleep(5000); 
        runOnUiThread(new Runnable() { 
         public void run() { 
          Intent mainIntent = new Intent(Splash_screen.this, MainActivity.class); 
          startActivity(mainIntent); 
         } 
        }); 



       } catch (InterruptedException e) { 
        e.printStackTrace(); 
       } finally { 

        finish(); 
       } 
      } 

     }; 
     logoTimer.start(); 
    } 
    } 
+0

2番目のイメージでは、アニメーションの開始オフセットを定義したり、アニメーションリスナーを終了アニメーションコールバックの最初のアニメーションに追加したりすることができます。あなたは今まで何を試しましたか? – Shaishav

+0

@Override public void onAnimationEnd(アニメーションアニメーション){ sogood.startAnimation(animation2); } –

+0

リスナーを追加しようとしましたが、最初の画像だけが動いて2番目は表示されません –

答えて

0

たぶん、あなたは正しくsogood ImageViewのの可視性を設定しませんでした。このSplashActivityのレイアウトを提供できる方が良いでしょう。

+0

私は間違ったパラメータを与えていた、それはritを得た、時々sille私:) –

+0

私はそれを移動する方法を教えてくれますもっと早く ? 2番目の画像ビュー? –

+0

あなたは、durationを短くすることができます。たとえば、 'animation.setDuration(3000);'です。あなたはこれを意味しますか? –

関連する問題