2016-05-12 6 views
2

Ich habe Probleme mit stop Bildansicht für einige Sekunden im Begrüßungsbildschirm mit Zoom-Animation. Ich versuche, ein add xml zoom2 und tak Maßstab von 1,0 bis 1,0 mit Dauer 2000, aber in splash.java ich weiß nicht, wie man das in guter Weise hinzufügen.Wie Bild zu zoomen und es für 2 Sekunden im Splash-Bildschirm zu stoppen

Bitte helfen Sie mir :)

zoom.xml

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android"> 
<scale 
android:duration="1500" 
android:fromXScale="0.0" 
android:fromYScale="0.0" 
android:pivotX="50%p" 
android:pivotY=50p" 
android:toXScale="1.0" 
android:toYScale="1.0"> 
</scale> 
</set> 

Splash.java

package com.example.maciek.polskieinternety; 

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.animation.Animation; 
import android.view.animation.AnimationUtils; 
import android.widget.ImageView; 

/** 
* Created by Maciek on 12.05.2016. 
*/ 
public class Splash extends Activity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.splashh); 


     final ImageView zoom = (ImageView) findViewById(R.id.imageView); 
     final Animation zoomAnimation = AnimationUtils.loadAnimation(getBaseContext(), R.anim.zoom); 
     zoom.startAnimation(zoomAnimation); 
     zoomAnimation.setAnimationListener(new Animation.AnimationListener() { 
      @Override 
      public void onAnimationStart(Animation animation) { 

      } 

      @Override 
      public void onAnimationEnd(Animation animation) { 
       finish(); 
       Intent i = new Intent(Splash.this,MainActivity.class); 
       startActivity(i); 
      } 

      @Override 
      public void onAnimationRepeat(Animation animation) { 

      } 
     }); 
    } 
} 

Antwort

2

In folgendem Code in Ihrem

onAnimationEnd()

Handler mHandler = new Handler(getMainLooper()); 
    Runnable mRunnable = new Runnable() { 
    @Override 
     public void run() { 
      finish(); 
      Intent i = new Intent(Splash.this,MainActivity.class); 
      startActivity(i); 

     } 
    }; 
mHandler.postDelayed(mRunnable, 2000); 
+0

THX, diese Hilfe :) im beginer und seine so hilfreich für mich :) –

0

Sie einen Handler mit postDelayed in Ihrem OnAnimationEnd verwenden können.

Verwandte Themen