Páginas

Eliminar la animación entre actividades
Remove animation between activities


Por defecto, siempre que comenzamos o terminamos una actividad en Android, ésta se presenta con una animación. En general este comportamiento pasa desapercibido, pero puede haber casos en que no sea deseable. Por ejemplo, si queremos navegar entre actividades sin que el usuario se percate de ello.

Para desactivar la animación de una actividad tendremos que crear un nuevo Theme en nuestro fichero de estilos, ubicado en values/styles.xml.

<style name="noAnimTheme" parent="android:Theme">
        <item name="android:windowAnimationStyle">@null</item>
</style>

A continuación, sólo nos queda indicar en el manifest de la aplicación qué actividades usarán ese estilo.

<activity android:name="jvel.android.kidsgames.MainActivity"
          android:theme="@style/noAnimTheme" >
</activity>

Si en lugar de eliminar la animación, lo que queremos es utilizar una específica, sólo tenemos que indicar cuál en el elemento android:windowAnimationStyle del fichero de estilos.

By default, when we throw or we finish an activity on Android, it is begun with an animation. Most times this behaviour is good, but we can remove it if we need.

To remove the animation, we have to create a new Theme in styles, placed on values/styles.xml.

<style name="noAnimTheme" parent="android:Theme">
        <item name="android:windowAnimationStyle">@null</item>
</style>

Next, we have to change manifest file to tell what activities must use our new style.

<activity android:name="jvel.android.kidsgames.MainActivity"
          android:theme="@style/noAnimTheme" >
</activity>

If we don´t want to remove the animation, but change it, we just have to write the wanted one in android:windowAnimationStyle.

No hay comentarios:

Publicar un comentario