Android: la animación se acorta por la vista de los padres

Actualmente tengo un ImageView al que estoy aplicando una animación a escala. Esta vista está dentro de un diseño relativo que tiene layout_height y layout_width establecidos como wrap_content. El problema es cuando la animación comienza hace que la vista de la imagen sea más grande que su disposición principal y la imagen entonces se corta. ¿Hay de alguna manera alrededor de esto?

Aquí hay una muestra de trabajo:

Archivo xml –

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="20dip" android:layout_gravity="center_horizontal"> <ImageView android:id="@+id/imgO" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/circle"/> </RelativeLayout> </LinearLayout> 

Archivo java

 ImageView imgO; ScaleAnimation makeSmaller; ScaleAnimation makeBigger; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.titlescreen); //Animation imgO = (ImageView)findViewById(R.id.imgO); makeSmaller = new ScaleAnimation((float)10.0, (float)1.0, (float)10.0, (float)1.0, Animation.RELATIVE_TO_SELF, (float)0.5, Animation.RELATIVE_TO_SELF, (float)0.5); makeSmaller.setAnimationListener(new MyAnimationListener()); makeSmaller.setFillAfter(true); makeSmaller.setDuration(500); makeBigger = new ScaleAnimation((float)1.0, (float)10.0, (float)1.0, (float)10.0, Animation.RELATIVE_TO_SELF, (float)0.5, Animation.RELATIVE_TO_SELF, (float)0.5); makeBigger.setAnimationListener(new MyAnimationListener()); makeBigger.setFillAfter(true); makeBigger.setDuration(750); imgO.startAnimation(makeBigger); } class MyAnimationListener implements AnimationListener { public void onAnimationEnd(Animation animation) { ScaleAnimation sa = (ScaleAnimation)animation; if (sa.equals(makeSmaller)) imgO.startAnimation(makeBigger); else imgO.startAnimation(makeSmaller); } public void onAnimationRepeat(Animation animation) { } public void onAnimationStart(Animation animation) { } } 

Gracias.

Un poco tarde para ti, pero para todos los que buscan una respuesta: Puedes llamar a setClipChildren(false) en los ViewGroups incluidos (como RelativeLayout o LinearLayout ).

He arreglado esto haciendo todo rellenar padre luego centrando las imágenes horizontal y verticalmente.

  • ¿Cuál es la forma correcta de especificar dimensiones en DIP desde el código Java?
  • Diseño de Android con layout_weight, layout_width y maxWidth
  • Rendimiento: Cómo evitar que requestLayout () exponga toda la jerarquía
  • ¿Qué pasa si dejo todas mis imágenes en la carpeta drawable-hdpi?
  • ¿Cómo expandir una altura de diseño con animación?
  • Forma de rectángulo como fondo hace que el fondo negro
  • Recursos de la cadena de fondo de Android
  • Efecto de desvanecimiento entre los diseños
  • Conceptos básicos de los píxeles independientes del dispositivo
  • Tamaño de ventana emergente en android
  • Center MoPub baner en SurfaceView
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.