Cómo crear el efecto de pulso ImageView con nueve animaciones androides de edad
Me pregunto cómo debo crear un efecto de pulso utilizando nueve animación marco androides olad.
Para entender mejor, digamos que tienes un ImageView y quieres tener un efecto de "pulso" como hacer que la imagen sea más pequeña y volver al tamaño original, la escala se centrará.
- Cómo alinear la imagen en el botón de imagen
- Cómo establecer un texto sobre una imagen?
- Cómo girar / voltear androide imageView?
- Cambiar dinámicamente la vista de imagen en el botón
- ¿Cómo crear una vista previa de vídeo en Android?
Yo uso nueve olad androids para compatibilidad hacia atrás.
Cualquier otra opción es bienvenida.
Gracias.
- Cómo agregar efectos de imagen en android?
- Android - Crossfade mutiple imágenes en un ImageView
- Tamaño de las imágenes en imageview android
- Programa Android para acercar y alejar con la ayuda de seekbar?
- Android cómo convertir pdf a imagen y carga en imageview
- Recortar imagen a cuadrado - Android
- Bitmap fuera de error de memoria en android ...
- Android: poner una imagen sobre otra imagen
R.anim.pulse
:
<scale xmlns:android="http://schemas.android.com/apk/res/android" android:duration="1000" android:fromXScale="1" android:fromYScale="1" android:pivotX="50%" android:pivotY="50%" android:repeatCount="1" android:repeatMode="reverse" android:toXScale="0.5" android:toYScale="0.5" />
ImageView imageView = (ImageView) findViewById(R.id.image); Animation pulse = AnimationUtils.loadAnimation(this, R.anim.pulse); imageView.startAnimation(pulse);
Heart_pulse.xml poner heart_pulse.xml en res / anim folder Añadir android: interpolator
Luego utilice en su actividad como a continuación
<?xml version="1.0" encoding="utf-8"?> <scale xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:fromXScale="1" android:fromYScale="1" android:pivotX="50%" android:pivotY="50%" android:toXScale="0.5" android:toYScale="0.5" android:duration="1000" android:repeatCount="infinite" android:repeatMode="reverse"/> ImageView imageView =(ImageView)findViewById(R.id.imageView); Animation pulse = AnimationUtils.loadAnimation(this, R.anim.heart_pulse); imageView.startAnimation(pulse);
Para utilizar la solución @ Matthias Robbers directamente desde el XML, puede hacer lo siguiente: crear 2 archivos:
1- pulse.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <scale xmlns:android="http://schemas.android.com/apk/res/android" android:fromXScale="1" android:fromYScale="1" android:pivotX="50%" android:pivotY="50%" android:toXScale="0.8" android:toYScale="0.8" android:duration="500" android:repeatCount="infinite" android:repeatMode="reverse"/> </set>
2- pulse_layout_animation.xml
<?xml version="1.0" encoding="utf-8"?> <layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android" android:animation="@anim/pulse"> </layoutAnimation>
Entonces en su archivo xml de diseño simplemente añada esta animación a cualquier vista que necesite, por ejemplo:
<ImageView android:layout_width="55dp" android:layout_height="55dp" android:src="@drawable/heart" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:layoutAnimation="@anim/pulse_layout_animation" />
- Cómo crear realmente pequeños botones en android de código?
- ¿Es la forma recomendada de dar formato a los números en una forma regional?