2011-10-25 3 views
1

Je souhaite fournir une animation lorsque mon application démarre. Je n'ai qu'un ImageView sur ma première activité et je veux charger mon activité avec une animation (peut-être aussi des animations jouant avec l'image) et après quelques secondes pour démarrer la deuxième activité avec une autre animation. Je ne suis pas très familier avec l'animation et comment puis-je créer des animations personnalisées, c'est pourquoi j'ai besoin d'un peu d'aide/suggestions/conseils pour que les animations soient belles.Android définir l'animation au démarrage de l'application

+0

Il est très difficile de comprendre ce que vous demandez. Avez-vous un problème pour démarrer votre application avec une animation ou voulez-vous de l'aide sur la façon de créer des animations? S'il vous plaît, essayez de reformuler votre question pour la rendre plus compréhensible. – Janusz

Répondre

2

Voici le code:

Initialisation:

ImageView loading = (ImageView) findViewById(R.id.loading_animation); 
AnimationDrawable loading_animation = (AnimationDrawable) loading.getBackground(); 

Afficher:

loading_animation.setVisible(true, true); 
loading_animation.start(); 

Cacher:

loading_animation.setVisible(false, false); 
loading_animation.stop(); 

Contexte de ImageView: drawable.xml (dans le dossier drawables)

<?xml version="1.0" encoding="utf-8"?> 
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" 
    android:oneshot="false"> 
    <item android:drawable="@drawable/loading_0" android:duration="500" /> 
    <item android:drawable="@drawable/loading_1" android:duration="500" /> 
    <item android:drawable="@drawable/loading_2" android:duration="500" /> 
    <item android:drawable="@drawable/loading_3" android:duration="500" /> 
    <item android:drawable="@drawable/loading_4" android:duration="500" /> 
    <item android:drawable="@drawable/loading_5" android:duration="500" /> 
    <item android:drawable="@drawable/loading_6" android:duration="500" /> 
    <item android:drawable="@drawable/loading_7" android:duration="500" /> 
    <item android:drawable="@drawable/loading_8" android:duration="500" /> 
</animation-list> 

Espérons que cela aide! N'oubliez pas que l'animation ne commencera pas si les fenêtres n'ont pas le focus !!

+0

Cela vous a-t-il aidé? –

+0

Je n'ai pas eu beaucoup de temps pour l'essayer, mais j'ai deux questions: ce qui est: 'loading_places_animation' et pourquoi vous définissez 9 images .. Je veux dire ce qu'ils font réellement? –

+0

Le chargement_places_animation est mal orthographié. Je vais le mettre à jour. Le drawable est un ensemble d'images qui créent une animation. Pensez-y par exemple, load_0 a un 'X', loading_1 a deux 'X', etc. Ainsi, en montrant l'un après l'autre, vous créez une animation. Bien sûr, ce n'est pas le seul moyen. –

Questions connexes