2016-05-31 213 views
3

我想這樣做(Please see the video)。我已經Google了它,但沒有找到任何解決方案。建議非常感謝。滑動屏幕上的移動物體的歡迎屏幕

+3

請閱讀此https://medium.com/@BashaChris/the-android-viewpager-has-become-a-fairly-popular-component-among-android-apps-its-simple-6bca403b16d4#.yrch7b8zv – xAqweRx

+1

並通過查看ViewPager.PageTransformer() – xAqweRx

+1

和一個礦http://stackoverflow.com/a/22501679/2685996 – xAqweRx

回答

0

你可以做到這一點我下面的步驟:

  1. 只需添加您的視頻資產文件夾.mp4擴展。
  2. 在啓動畫面上使用此方法播放視頻。 vidHolder is videoview

    private void PlayVideo() { 
        Uri video = null; 
    
        DisplayMetrics metrics = new DisplayMetrics(); 
        getWindowManager().getDefaultDisplay().getMetrics(metrics); 
        try { 
         Intent intent = getIntent(); 
         if (getIntent().getExtras() != null) { 
          isLogout = intent.getStringExtra("isLogout"); 
         } 
         /* if (isLogout != null && isLogout.equalsIgnoreCase("true")) { 
          playAnimation(); 
          //*video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.logutvideo);*// 
         } else {*/ 
         video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.splash_revised); 
         // } 
         vidHolder.setVideoURI(video); 
         vidHolder.setVisibility(View.VISIBLE); 
         vidHolder.setZOrderOnTop(false); 
         vidHolder.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { 
          @Override 
          public void onPrepared(MediaPlayer mp) { 
           Log.e("First","11"); 
           vidHolder.seekTo(0); 
           vidHolder.start(); 
           new Handler().postDelayed(new Runnable() { 
            @Override 
            public void run() { 
             placeholder.setVisibility(View.GONE); 
            } 
           }, 300); 
          } 
         }); 
    
         vidHolder.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { 
          public void onCompletion(MediaPlayer mp) { 
           jump(); 
          } 
         }); 
        } catch (Exception ex) { 
         jump(); 
        } 
    } 
    
+0

我想在左右滑動屏幕時移動對象從右到左 –

+0

將動畫應用到單個對象。可能會有所幫助.http://www.vogella.com/tutorials/AndroidAnimation/article.html –