Ver animar ir detrás de otro diseño

Estoy tratando de animar una vista a otro diseño, pero tengo un problema, porque mi vista está detrás del diseño. He intentado poner android:animateLayoutChanges="true" , pero sin éxito.
Mi código:
Layout.xml

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:animateLayoutChanges="true"> <RadioButton android:id="@+id/radioButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New RadioButton" /> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="20dp" android:animateLayoutChanges="true" android:background="#ffffff"> </LinearLayout> </RelativeLayout> 

Mi clase de actividad:

 public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public void onWindowFocusChanged(boolean hasFocus) { float x = 300; float y = 300; RadioButton button = (RadioButton) findViewById(R.id.radioButton); button.animate().setDuration(10000).x(x).y(y); } } 

Los elementos se dibujarán en el mismo orden en que se ordenan en el diseño. Para su diseño, el RadioButton se dibujará primero y luego el LinearLayout. Si se superponen, el LinearLayout se dibujará sobre el RadioButton.

Solución Parte 1: Gire el orden de RadioButton y LinearLayout para que el RadioButton siempre se dibuje en último lugar.

 <RelativeLayout android:id="@+id/final_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="30dp" android:background="#ffffff"> </RelativeLayout> <RadioButton android:id="@+id/radioButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New RadioButton" /> 

Una explicación más rigurosa en el sitio del desarrollador de Android .

Solución Parte # 2: Sin relación con el punto que he hecho anteriormente, pero probablemente igual de importante, es necesario iniciar el animador. Fuente actualizada a continuación:

 public class MainActivity extends AppCompatActivity { private RadioButton mRadioButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mRadioButton = (RadioButton) findViewById(R.id.radioButton); } @Override public void onWindowFocusChanged(boolean hasFocus) { float x = 300; float y = 300; ViewPropertyAnimator animator = mRadioButton.animate().setDuration(10000).x(x).y(y); animator.setListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) {} @Override public void onAnimationEnd(Animator animation) { Log.d(TAG, "onAnimationEnd"); } @Override public void onAnimationCancel(Animator animation) {} @Override public void onAnimationRepeat(Animator animation) {} }) animator.start(); } private static final String TAG = MainActivity.class.getSimpleName(); } 

Probado, animado al iniciar la aplicación en Android 5.1.

Sólo dar todas las propiedades de elementos de diseño xml como android:clipChildren="false" & android:clipToPadding="false" . Y no te olvides de hacer animatedView.bringToFront()

Tienen el mismo problema antes del mes y encontraron la solución después de trabajar duro par de días. Encontrar mi aquí

Permítanme proporcionarles la solución con respecto a la pantalla 480 x 854 ppp mdpi

Pantalla de 480 x 854 píxeles

Escenario 1: Quiere que RadioButton cruce el LinearLayout con RelativeLayout como Parent ViewGroup de lo que necesita para arreglar su orden z. Realice los cambios como a continuación. La animación comienza desde el punto A (0,0) hasta el punto C (300,300 ) Con el RelativeLayout.

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="20dp" android:background="#ffffff"> </LinearLayout> <RadioButton android:id="@+id/radioButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New RadioButton" /> </RelativeLayout> 

Escenario 2: Quiere que RadioButton se anime en el LinearLayout con LinearLayout como ViewGroup principal de lo que necesita para establecer el diseño como se muestra a continuación. La animación comienza desde el punto B (20,20) (según el valor layout_margin ) hasta el punto D (320,320) con respecto al RelativeLayout.

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="20dp" android:background="#ffffff"> <RadioButton android:id="@+id/radioButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New RadioButton" /> </LinearLayout> </RelativeLayout> 

Escenario 3: Desea que RadioButton anime a través de LinearLayout con LinearLayout como ViewGroup padre y su valor x o y va más allá del tamaño de límites LinearLayout en cualquier dirección, por ejemplo, x = 800> 480 píxeles O Y = 1200> 854 píxeles

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" <!-- Allow all the children to go out of their parent boundaries --> android:clipChildren="false" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="20dp" <!-- Allow all the children to go out of their parent boundaries --> android:clipChildren="false" <!-- Do not clip the children at the padding ie allow to children go beyond the padding --> android:clipToPadding="false" android:background="#ffffff"> <RadioButton android:id="@+id/radioButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New RadioButton" /> </LinearLayout> </RelativeLayout> 

Espero que eso ayude…
Codificación feliz

No estoy seguro de lo que estás intentando lograr, pero si estás moviendo a un niño View fuera de su contenedor, debes desactivar los clipToChilder y clipToPadding en el contenedor para ver al niño moviéndose fuera del padre:

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:clipChildren="false" android:clipToPadding="false"> ... </RelativeLayout> 

De todos modos, si usted está experimentando z-order problema en alguna vista puede utilizar el método bringToFront() ; en tu caso:

  final RadioButton button = (RadioButton) findViewById(R.id.radioButton); button.animate().setDuration(10000).x(x).y(y).setListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { button.bringToFront(); } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); 

Basado en el comentario de sir Karaokyo que usted respondió a entonces sugiero que esto es lo que quiere

 RadioButton r1; // suppose you already referenced it LinearLayout l1; // // Animation anim = AnimationUtils.loadAnimation(getBaseContext(), R.anim.abc_slide_in_top); // the R.anim. blah blah is the preferred animation you want //when the time comes if(r1.getParent() != null) ((ViewGroup)r1.getParent()).removeView(r1); l1.addView(r1); r1.startAnimation(anim); // you can create an animation listener and add the view when the animation //starts 

La captura aquí es, se verá como la forma en que lo quería.

La solución más simple es intentar relayout en xml de modo que RadioButton sea mostrado después de LinearLayout.

Llame a bringchildTofront (yourradiobutton) antes de iniciar la animación o Si desea más control en el orden de dibujo, entonces Extend RelativeLayout y override

 protected int getChildDrawingOrder (int childCount, int i) 
  • Efecto extraño con ImageView startAnimation en ListView
  • Cómo ampliar el espacio entre RecyclerView Item mientras se desplaza
  • Anime el botón Fab cruzar para marcar
  • Agrega parpadea al artículo personalizado de listview?
  • PopupWindow Enter Exit La animación no funciona en Marshmallow (23)
  • Android- simple fade out y fade in animación para viewflipper
  • Tinder como vista de aplicación con Animation
  • Diferentes fling (swipe) de velocidad en diferentes dispositivos Android con la misma densidad
  • Animación de desplazamiento de la lista de Android
  • Vista de Android que desaparece cuando se sale de los padres
  • Barra de progreso circular
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.