2016-07-12 9 views
1

Keine Animation könnte man auf Schaltaktivität 1. Aktivität gesehen werden -------------- 2. Aktivität Keine Animation Hier ist das SnippetKEINE Animation mit Methode overridePendingTransition();

private void StartAnimations() { 
    Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha); 
    anim.reset(); 
    LinearLayout l=(LinearLayout) findViewById(R.id.lin_lay); 
    l.clearAnimation(); 
    l.startAnimation(anim); 

    anim = AnimationUtils.loadAnimation(this, R.anim.translate); 
    anim.reset(); 
    ImageView iv = (ImageView) findViewById(R.id.splash); 
    iv.clearAnimation(); 
    iv.startAnimation(anim); 

    splashTread = new Thread() { 
     @Override 
     public void run() { 
      try { 
       int waited = 0; 
       // Splash screen pause time 
       while (waited < 3500) { 
        sleep(100); 
        waited += 100; 
       } 
       **Intent intent = new Intent(SplashScreen.this, 
         MainActivity.class); 
       intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); 
       startActivity(intent); 
       overridePendingTransition(R.anim.left_in,R.anim.right_in);** 

       SplashScreen.this.finish(); 
      } catch (InterruptedException e) { 
       // do nothing 
      } finally { 
       SplashScreen.this.finish(); 
      } 

     } 
    }; 
    splashTread.start(); 

} 

hier ist meine Animationsdatei

slide_left_in.xml

 <set xmlns:android="http://schemas.android.com/apk/res/android" 
android:shareInterpolator="false" > 
<translate android:duration="5000" android:fromXDelta="-100%" android:toXDelta="0%"/> 
<alpha android:duration="5000" android:fromAlpha="0.0" android:toAlpha="1.0" /> 

slide _right_out.xml

<set xmlns:android="http://schemas.android.com/apk/res/android" 
android:shareInterpolator="false" > 
<translate android:duration="5000" android:fromXDelta="0%" android:toXDelta="100%"/> 
<alpha android:duration="5000" android:fromAlpha="1.0" android:toAlpha="0.0" /> 

Also im Grunde OverridePendingTransition Doesnt Do Anything

Antwort

0

Bei der ersten Änderung der Namen in Funktionen als overridePendingTransition(R.anim.slide_left_in,R.anim.slide_right_in);

statt

overridePendingTransition(R.anim.left_in,R.anim.right_in);

und intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);

+0

Keine Änderung Nach alldem Too Jede andere Lösung? –

0
SplashScreen.this.finish(); 

vor overridePendingTransition() entfernen und

intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); 

etwas wie dieses entfernen:

Intent intent = new Intent(SplashScreen.this, MainActivity.class); 
startActivity(intent); 
SplashScreen.this.finish(); 
overridePendingTransition(R.anim.left_in,R.anim.right_in); 
+0

Keine Änderung Sir Es ist das gleiche –

1

Sie können dieses verwenden, wie ich mit diesem gearbeitet haben. Sie AnimationUtils nicht, weil in Aktivität verwenden, muss es nur overridePendingTransition ...

public class SplashActivity extends AppCompatActivity { 

    private static final int SPLASH_TIME = 3000; 
    AppPreference preference; 


    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_splash); 
     preference=new AppPreference(getApplicationContext()); 

     new Handler().postDelayed(new Runnable() { 
      @Override 
      public void run() { 

       if(preference.getLoggedIn()){ 
        Intent intent=new Intent(SplashActivity.this,MenuActivity.class); 
        startActivity(intent); 
        overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up); 
       } 
       else{ 
        Intent intent=new Intent(SplashActivity.this,LaunchActivity.class); 
        startActivity(intent); 
        overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up); 
       } 


       finish(); 
      } 
     },SPLASH_TIME); 
    } 
} 
Verwandte Themen