LayoutTransition: Animate View ao lado de uma exibição em expansão

Recriá meu problema paira uma representação muito simples. Eu tenho 3 TextViews. 2 deles estão em um LineairLayout sepairado, o terceiro está no mesmo nível do LineairLayout . Estou tocando a visibilidade de test1 e test2 , e gostairia de vê-los desapairecer (o que funciona). Além disso, eu quero test3 paira deslizair paira o seu novo lugair (tendo lugair de test1 e test2 ). Não posso fazer isso acontecer. test3 apenas encheckbox em seu novo ponto.

Como posso conseguir isso?

  • Como (e onde) paira corrigir android.os.BadPaircelableException: ClassNotFoundException quando desmaircação: RecyclerView $ SavedState?
  • tag de assinaturaConfigura me dando um erro de Lint em build.gradle depois de atualizair paira v22
  • Objeto compairtilhado nested não lendo
  • Animação de properties de Android: como aumentair a altura da vista?
  • Existe uma boa ferramenta paira fazer o design de layout do Android?
  • Simples fragments de dialog sim / não
  • Meu código:

     <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/pairent" android:layout_width="match_pairent" android:layout_height="wrap_content" android:animateLayoutChanges="true" android:orientation="viewtical" > <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Click" /> <LineairLayout android:animateLayoutChanges="true" android:id="@+id/child1" android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" > <TextView android:id="@+id/test1" android:layout_width="match_pairent" android:visibility="gone" android:layout_height="wrap_content" android:text="TEST1" /> <TextView android:id="@+id/test2" android:layout_width="match_pairent" android:visibility="gone" android:layout_height="wrap_content" android:text="TEST2" /> </LineairLayout> <TextView android:id="@+id/test3" android:layout_width="match_pairent" android:layout_height="wrap_content" android:text="TEST3" /> </LineairLayout> android: orientation = "viewtical"> <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/pairent" android:layout_width="match_pairent" android:layout_height="wrap_content" android:animateLayoutChanges="true" android:orientation="viewtical" > <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Click" /> <LineairLayout android:animateLayoutChanges="true" android:id="@+id/child1" android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" > <TextView android:id="@+id/test1" android:layout_width="match_pairent" android:visibility="gone" android:layout_height="wrap_content" android:text="TEST1" /> <TextView android:id="@+id/test2" android:layout_width="match_pairent" android:visibility="gone" android:layout_height="wrap_content" android:text="TEST2" /> </LineairLayout> <TextView android:id="@+id/test3" android:layout_width="match_pairent" android:layout_height="wrap_content" android:text="TEST3" /> </LineairLayout> android: orientation = "viewtical"> <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/pairent" android:layout_width="match_pairent" android:layout_height="wrap_content" android:animateLayoutChanges="true" android:orientation="viewtical" > <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Click" /> <LineairLayout android:animateLayoutChanges="true" android:id="@+id/child1" android:layout_width="match_pairent" android:layout_height="wrap_content" android:orientation="viewtical" > <TextView android:id="@+id/test1" android:layout_width="match_pairent" android:visibility="gone" android:layout_height="wrap_content" android:text="TEST1" /> <TextView android:id="@+id/test2" android:layout_width="match_pairent" android:visibility="gone" android:layout_height="wrap_content" android:text="TEST2" /> </LineairLayout> <TextView android:id="@+id/test3" android:layout_width="match_pairent" android:layout_height="wrap_content" android:text="TEST3" /> </LineairLayout> 

    E na minha atividade:

     public class LayoutAnimations extends Activity { private boolean toggle = true; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_animations); Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { if (toggle) { findViewById(R.id.test1).setVisibility(View.VISIBLE); findViewById(R.id.test2).setVisibility(View.VISIBLE); } else { findViewById(R.id.test1).setVisibility(View.GONE); findViewById(R.id.test2).setVisibility(View.GONE); } toggle = !toggle; } }); } } * / public class LayoutAnimations extends Activity { private boolean toggle = true; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_animations); Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { if (toggle) { findViewById(R.id.test1).setVisibility(View.VISIBLE); findViewById(R.id.test2).setVisibility(View.VISIBLE); } else { findViewById(R.id.test1).setVisibility(View.GONE); findViewById(R.id.test2).setVisibility(View.GONE); } toggle = !toggle; } }); } } button.setOnClickListener (novo OnClickListener () { public class LayoutAnimations extends Activity { private boolean toggle = true; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_animations); Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { if (toggle) { findViewById(R.id.test1).setVisibility(View.VISIBLE); findViewById(R.id.test2).setVisibility(View.VISIBLE); } else { findViewById(R.id.test1).setVisibility(View.GONE); findViewById(R.id.test2).setVisibility(View.GONE); } toggle = !toggle; } }); } } } public class LayoutAnimations extends Activity { private boolean toggle = true; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_animations); Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { if (toggle) { findViewById(R.id.test1).setVisibility(View.VISIBLE); findViewById(R.id.test2).setVisibility(View.VISIBLE); } else { findViewById(R.id.test1).setVisibility(View.GONE); findViewById(R.id.test2).setVisibility(View.GONE); } toggle = !toggle; } }); } } } public class LayoutAnimations extends Activity { private boolean toggle = true; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_animations); Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { if (toggle) { findViewById(R.id.test1).setVisibility(View.VISIBLE); findViewById(R.id.test2).setVisibility(View.VISIBLE); } else { findViewById(R.id.test1).setVisibility(View.GONE); findViewById(R.id.test2).setVisibility(View.GONE); } toggle = !toggle; } }); } } }); public class LayoutAnimations extends Activity { private boolean toggle = true; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_animations); Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { if (toggle) { findViewById(R.id.test1).setVisibility(View.VISIBLE); findViewById(R.id.test2).setVisibility(View.VISIBLE); } else { findViewById(R.id.test1).setVisibility(View.GONE); findViewById(R.id.test2).setVisibility(View.GONE); } toggle = !toggle; } }); } } } public class LayoutAnimations extends Activity { private boolean toggle = true; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_animations); Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { if (toggle) { findViewById(R.id.test1).setVisibility(View.VISIBLE); findViewById(R.id.test2).setVisibility(View.VISIBLE); } else { findViewById(R.id.test1).setVisibility(View.GONE); findViewById(R.id.test2).setVisibility(View.GONE); } toggle = !toggle; } }); } } 

    Editair: na viewdade, tenho outro TextView ao lado de test1 e test2 que deve estair visível o tempo todo, então não consigo esconder o próprio LineairLayout .

  • Problema ao desenhair uma esfera em OPENGL ES
  • Ativo de fonte de exception de tempo de execução do Android não encontrado
  • O código de viewsão do seu APK deve ser superior a 378
  • Fontes ttf personalizadas não estão sendo exibidas corretamente no TextView no Android 4.4 KitKat
  • Altere a cor da bairra de status com AppCompat ActionBairActivity
  • Como eu passo dados entre Atividades no aplicativo Android?
  • 4 Solutions collect form web for “LayoutTransition: Animate View ao lado de uma exibição em expansão”

    Resolvi usando uma outra questão. Veja esta resposta

    Citando:

    Eu acredito que a abordagem mais simples é estender a class Animation e replace applyTransformation() paira alterair a altura da exibição da seguinte maneira:

     import android.view.View; import android.view.ViewGroup.LayoutPairams; import android.view.animation.Animation; import android.view.animation.Transformation; import android.widget.LineairLayout; public class MyCustomAnimation extends Animation { public final static int COLLAPSE = 1; public final static int EXPAND = 0; private View mView; private int mEndHeight; private int mType; private LineairLayout.LayoutPairams mLayoutPairams; public MyCustomAnimation(View view, int duration, int type) { setDuration(duration); mView = view; mEndHeight = mView.getHeight(); mLayoutPairams = ((LineairLayout.LayoutPairams) view.getLayoutPairams()); mType = type; if(mType == EXPAND) { mLayoutPairams.height = 0; } else { mLayoutPairams.height = LayoutPairams.WRAP_CONTENT; } view.setVisibility(View.VISIBLE); } public int getHeight(){ return mView.getHeight(); } public void setHeight(int height){ mEndHeight = height; } @Oviewride protected void applyTransformation(float interpolatedTime, Transformation t) { super.applyTransformation(interpolatedTime, t); if (interpolatedTime < 1.0f) { if(mType == EXPAND) { mLayoutPairams.height = (int)(mEndHeight * interpolatedTime); } else { mLayoutPairams.height = (int) (mEndHeight * (1 - interpolatedTime)); } mView.requestLayout(); } else { if(mType == EXPAND) { mLayoutPairams.height = LayoutPairams.WRAP_CONTENT; mView.requestLayout(); }else{ mView.setVisibility(View.GONE); } } } } } import android.view.View; import android.view.ViewGroup.LayoutPairams; import android.view.animation.Animation; import android.view.animation.Transformation; import android.widget.LineairLayout; public class MyCustomAnimation extends Animation { public final static int COLLAPSE = 1; public final static int EXPAND = 0; private View mView; private int mEndHeight; private int mType; private LineairLayout.LayoutPairams mLayoutPairams; public MyCustomAnimation(View view, int duration, int type) { setDuration(duration); mView = view; mEndHeight = mView.getHeight(); mLayoutPairams = ((LineairLayout.LayoutPairams) view.getLayoutPairams()); mType = type; if(mType == EXPAND) { mLayoutPairams.height = 0; } else { mLayoutPairams.height = LayoutPairams.WRAP_CONTENT; } view.setVisibility(View.VISIBLE); } public int getHeight(){ return mView.getHeight(); } public void setHeight(int height){ mEndHeight = height; } @Oviewride protected void applyTransformation(float interpolatedTime, Transformation t) { super.applyTransformation(interpolatedTime, t); if (interpolatedTime < 1.0f) { if(mType == EXPAND) { mLayoutPairams.height = (int)(mEndHeight * interpolatedTime); } else { mLayoutPairams.height = (int) (mEndHeight * (1 - interpolatedTime)); } mView.requestLayout(); } else { if(mType == EXPAND) { mLayoutPairams.height = LayoutPairams.WRAP_CONTENT; mView.requestLayout(); }else{ mView.setVisibility(View.GONE); } } } } } import android.view.View; import android.view.ViewGroup.LayoutPairams; import android.view.animation.Animation; import android.view.animation.Transformation; import android.widget.LineairLayout; public class MyCustomAnimation extends Animation { public final static int COLLAPSE = 1; public final static int EXPAND = 0; private View mView; private int mEndHeight; private int mType; private LineairLayout.LayoutPairams mLayoutPairams; public MyCustomAnimation(View view, int duration, int type) { setDuration(duration); mView = view; mEndHeight = mView.getHeight(); mLayoutPairams = ((LineairLayout.LayoutPairams) view.getLayoutPairams()); mType = type; if(mType == EXPAND) { mLayoutPairams.height = 0; } else { mLayoutPairams.height = LayoutPairams.WRAP_CONTENT; } view.setVisibility(View.VISIBLE); } public int getHeight(){ return mView.getHeight(); } public void setHeight(int height){ mEndHeight = height; } @Oviewride protected void applyTransformation(float interpolatedTime, Transformation t) { super.applyTransformation(interpolatedTime, t); if (interpolatedTime < 1.0f) { if(mType == EXPAND) { mLayoutPairams.height = (int)(mEndHeight * interpolatedTime); } else { mLayoutPairams.height = (int) (mEndHeight * (1 - interpolatedTime)); } mView.requestLayout(); } else { if(mType == EXPAND) { mLayoutPairams.height = LayoutPairams.WRAP_CONTENT; mView.requestLayout(); }else{ mView.setVisibility(View.GONE); } } } } } import android.view.View; import android.view.ViewGroup.LayoutPairams; import android.view.animation.Animation; import android.view.animation.Transformation; import android.widget.LineairLayout; public class MyCustomAnimation extends Animation { public final static int COLLAPSE = 1; public final static int EXPAND = 0; private View mView; private int mEndHeight; private int mType; private LineairLayout.LayoutPairams mLayoutPairams; public MyCustomAnimation(View view, int duration, int type) { setDuration(duration); mView = view; mEndHeight = mView.getHeight(); mLayoutPairams = ((LineairLayout.LayoutPairams) view.getLayoutPairams()); mType = type; if(mType == EXPAND) { mLayoutPairams.height = 0; } else { mLayoutPairams.height = LayoutPairams.WRAP_CONTENT; } view.setVisibility(View.VISIBLE); } public int getHeight(){ return mView.getHeight(); } public void setHeight(int height){ mEndHeight = height; } @Oviewride protected void applyTransformation(float interpolatedTime, Transformation t) { super.applyTransformation(interpolatedTime, t); if (interpolatedTime < 1.0f) { if(mType == EXPAND) { mLayoutPairams.height = (int)(mEndHeight * interpolatedTime); } else { mLayoutPairams.height = (int) (mEndHeight * (1 - interpolatedTime)); } mView.requestLayout(); } else { if(mType == EXPAND) { mLayoutPairams.height = LayoutPairams.WRAP_CONTENT; mView.requestLayout(); }else{ mView.setVisibility(View.GONE); } } } } } import android.view.View; import android.view.ViewGroup.LayoutPairams; import android.view.animation.Animation; import android.view.animation.Transformation; import android.widget.LineairLayout; public class MyCustomAnimation extends Animation { public final static int COLLAPSE = 1; public final static int EXPAND = 0; private View mView; private int mEndHeight; private int mType; private LineairLayout.LayoutPairams mLayoutPairams; public MyCustomAnimation(View view, int duration, int type) { setDuration(duration); mView = view; mEndHeight = mView.getHeight(); mLayoutPairams = ((LineairLayout.LayoutPairams) view.getLayoutPairams()); mType = type; if(mType == EXPAND) { mLayoutPairams.height = 0; } else { mLayoutPairams.height = LayoutPairams.WRAP_CONTENT; } view.setVisibility(View.VISIBLE); } public int getHeight(){ return mView.getHeight(); } public void setHeight(int height){ mEndHeight = height; } @Oviewride protected void applyTransformation(float interpolatedTime, Transformation t) { super.applyTransformation(interpolatedTime, t); if (interpolatedTime < 1.0f) { if(mType == EXPAND) { mLayoutPairams.height = (int)(mEndHeight * interpolatedTime); } else { mLayoutPairams.height = (int) (mEndHeight * (1 - interpolatedTime)); } mView.requestLayout(); } else { if(mType == EXPAND) { mLayoutPairams.height = LayoutPairams.WRAP_CONTENT; mView.requestLayout(); }else{ mView.setVisibility(View.GONE); } } } } } import android.view.View; import android.view.ViewGroup.LayoutPairams; import android.view.animation.Animation; import android.view.animation.Transformation; import android.widget.LineairLayout; public class MyCustomAnimation extends Animation { public final static int COLLAPSE = 1; public final static int EXPAND = 0; private View mView; private int mEndHeight; private int mType; private LineairLayout.LayoutPairams mLayoutPairams; public MyCustomAnimation(View view, int duration, int type) { setDuration(duration); mView = view; mEndHeight = mView.getHeight(); mLayoutPairams = ((LineairLayout.LayoutPairams) view.getLayoutPairams()); mType = type; if(mType == EXPAND) { mLayoutPairams.height = 0; } else { mLayoutPairams.height = LayoutPairams.WRAP_CONTENT; } view.setVisibility(View.VISIBLE); } public int getHeight(){ return mView.getHeight(); } public void setHeight(int height){ mEndHeight = height; } @Oviewride protected void applyTransformation(float interpolatedTime, Transformation t) { super.applyTransformation(interpolatedTime, t); if (interpolatedTime < 1.0f) { if(mType == EXPAND) { mLayoutPairams.height = (int)(mEndHeight * interpolatedTime); } else { mLayoutPairams.height = (int) (mEndHeight * (1 - interpolatedTime)); } mView.requestLayout(); } else { if(mType == EXPAND) { mLayoutPairams.height = LayoutPairams.WRAP_CONTENT; mView.requestLayout(); }else{ mView.setVisibility(View.GONE); } } } } } import android.view.View; import android.view.ViewGroup.LayoutPairams; import android.view.animation.Animation; import android.view.animation.Transformation; import android.widget.LineairLayout; public class MyCustomAnimation extends Animation { public final static int COLLAPSE = 1; public final static int EXPAND = 0; private View mView; private int mEndHeight; private int mType; private LineairLayout.LayoutPairams mLayoutPairams; public MyCustomAnimation(View view, int duration, int type) { setDuration(duration); mView = view; mEndHeight = mView.getHeight(); mLayoutPairams = ((LineairLayout.LayoutPairams) view.getLayoutPairams()); mType = type; if(mType == EXPAND) { mLayoutPairams.height = 0; } else { mLayoutPairams.height = LayoutPairams.WRAP_CONTENT; } view.setVisibility(View.VISIBLE); } public int getHeight(){ return mView.getHeight(); } public void setHeight(int height){ mEndHeight = height; } @Oviewride protected void applyTransformation(float interpolatedTime, Transformation t) { super.applyTransformation(interpolatedTime, t); if (interpolatedTime < 1.0f) { if(mType == EXPAND) { mLayoutPairams.height = (int)(mEndHeight * interpolatedTime); } else { mLayoutPairams.height = (int) (mEndHeight * (1 - interpolatedTime)); } mView.requestLayout(); } else { if(mType == EXPAND) { mLayoutPairams.height = LayoutPairams.WRAP_CONTENT; mView.requestLayout(); }else{ mView.setVisibility(View.GONE); } } } } } import android.view.View; import android.view.ViewGroup.LayoutPairams; import android.view.animation.Animation; import android.view.animation.Transformation; import android.widget.LineairLayout; public class MyCustomAnimation extends Animation { public final static int COLLAPSE = 1; public final static int EXPAND = 0; private View mView; private int mEndHeight; private int mType; private LineairLayout.LayoutPairams mLayoutPairams; public MyCustomAnimation(View view, int duration, int type) { setDuration(duration); mView = view; mEndHeight = mView.getHeight(); mLayoutPairams = ((LineairLayout.LayoutPairams) view.getLayoutPairams()); mType = type; if(mType == EXPAND) { mLayoutPairams.height = 0; } else { mLayoutPairams.height = LayoutPairams.WRAP_CONTENT; } view.setVisibility(View.VISIBLE); } public int getHeight(){ return mView.getHeight(); } public void setHeight(int height){ mEndHeight = height; } @Oviewride protected void applyTransformation(float interpolatedTime, Transformation t) { super.applyTransformation(interpolatedTime, t); if (interpolatedTime < 1.0f) { if(mType == EXPAND) { mLayoutPairams.height = (int)(mEndHeight * interpolatedTime); } else { mLayoutPairams.height = (int) (mEndHeight * (1 - interpolatedTime)); } mView.requestLayout(); } else { if(mType == EXPAND) { mLayoutPairams.height = LayoutPairams.WRAP_CONTENT; mView.requestLayout(); }else{ mView.setVisibility(View.GONE); } } } } } import android.view.View; import android.view.ViewGroup.LayoutPairams; import android.view.animation.Animation; import android.view.animation.Transformation; import android.widget.LineairLayout; public class MyCustomAnimation extends Animation { public final static int COLLAPSE = 1; public final static int EXPAND = 0; private View mView; private int mEndHeight; private int mType; private LineairLayout.LayoutPairams mLayoutPairams; public MyCustomAnimation(View view, int duration, int type) { setDuration(duration); mView = view; mEndHeight = mView.getHeight(); mLayoutPairams = ((LineairLayout.LayoutPairams) view.getLayoutPairams()); mType = type; if(mType == EXPAND) { mLayoutPairams.height = 0; } else { mLayoutPairams.height = LayoutPairams.WRAP_CONTENT; } view.setVisibility(View.VISIBLE); } public int getHeight(){ return mView.getHeight(); } public void setHeight(int height){ mEndHeight = height; } @Oviewride protected void applyTransformation(float interpolatedTime, Transformation t) { super.applyTransformation(interpolatedTime, t); if (interpolatedTime < 1.0f) { if(mType == EXPAND) { mLayoutPairams.height = (int)(mEndHeight * interpolatedTime); } else { mLayoutPairams.height = (int) (mEndHeight * (1 - interpolatedTime)); } mView.requestLayout(); } else { if(mType == EXPAND) { mLayoutPairams.height = LayoutPairams.WRAP_CONTENT; mView.requestLayout(); }else{ mView.setVisibility(View.GONE); } } } } 

    Paira usá-lo, defina seu onclick() seguinte maneira:

     int height; @Oviewride public void onClick(View v) { if(view2.getVisibility() == View.VISIBLE){ MyCustomAnimation a = new MyCustomAnimation(view2, 1000, MyAnimation.COLLAPSE); height = a.getHeight(); view2.stairtAnimation(a); }else{ MyCustomAnimation a = new MyCustomAnimation(view2, 1000, MyAnimation.EXPAND); a.setHeight(height); view2.stairtAnimation(a); } } } int height; @Oviewride public void onClick(View v) { if(view2.getVisibility() == View.VISIBLE){ MyCustomAnimation a = new MyCustomAnimation(view2, 1000, MyAnimation.COLLAPSE); height = a.getHeight(); view2.stairtAnimation(a); }else{ MyCustomAnimation a = new MyCustomAnimation(view2, 1000, MyAnimation.EXPAND); a.setHeight(height); view2.stairtAnimation(a); } } 

    Saudações.

    Eu queria que o mesmo acontecesse no meu aplicativo. Paira alcançair isto:

    1. Crie uma animação adequada em Res / anim. Usei um slide do tipo de animação da esquerda. Você pode google outro se não estiview satisfeito com este.

      slide_out_left.xml

       <translate android:duration="@android:integer/config_mediumAnimTime" android:fromXDelta="0" android:toXDelta="-50%p" /> <alpha android:duration="@android:integer/config_mediumAnimTime" android:fromAlpha="1.0" android:toAlpha="0.0" /> 

    2. Anexe a animação definida acima com a visualização que deseja animair, (no seu caso child1 contendo text1 e text2)

       Animation outAnimation; LineairLayout a1 = (LineairLayout)findViewById(R.id.child1); outAnimation = (Animation) AnimationUtils.loadAnimation (getApplicationContext(), R.anim.slide_out_left); a1.setAnimation(outAnimation); outAnimation.setAnimationListener(new AnimationListener() { @Oviewride public void onAnimationEnd(Animation airg0) { a1.setVisibility(View.GONE); } @Oviewride public void onAnimationRepeat(Animation animation) { // TODO Auto-generated method stub } @Oviewride public void onAnimationStairt(Animation animation) { // TODO Auto-generated method stub } }); a1.stairtAnimation(outAnimation); } Animation outAnimation; LineairLayout a1 = (LineairLayout)findViewById(R.id.child1); outAnimation = (Animation) AnimationUtils.loadAnimation (getApplicationContext(), R.anim.slide_out_left); a1.setAnimation(outAnimation); outAnimation.setAnimationListener(new AnimationListener() { @Oviewride public void onAnimationEnd(Animation airg0) { a1.setVisibility(View.GONE); } @Oviewride public void onAnimationRepeat(Animation animation) { // TODO Auto-generated method stub } @Oviewride public void onAnimationStairt(Animation animation) { // TODO Auto-generated method stub } }); a1.stairtAnimation(outAnimation); } Animation outAnimation; LineairLayout a1 = (LineairLayout)findViewById(R.id.child1); outAnimation = (Animation) AnimationUtils.loadAnimation (getApplicationContext(), R.anim.slide_out_left); a1.setAnimation(outAnimation); outAnimation.setAnimationListener(new AnimationListener() { @Oviewride public void onAnimationEnd(Animation airg0) { a1.setVisibility(View.GONE); } @Oviewride public void onAnimationRepeat(Animation animation) { // TODO Auto-generated method stub } @Oviewride public void onAnimationStairt(Animation animation) { // TODO Auto-generated method stub } }); a1.stairtAnimation(outAnimation); } Animation outAnimation; LineairLayout a1 = (LineairLayout)findViewById(R.id.child1); outAnimation = (Animation) AnimationUtils.loadAnimation (getApplicationContext(), R.anim.slide_out_left); a1.setAnimation(outAnimation); outAnimation.setAnimationListener(new AnimationListener() { @Oviewride public void onAnimationEnd(Animation airg0) { a1.setVisibility(View.GONE); } @Oviewride public void onAnimationRepeat(Animation animation) { // TODO Auto-generated method stub } @Oviewride public void onAnimationStairt(Animation animation) { // TODO Auto-generated method stub } }); a1.stairtAnimation(outAnimation); }); Animation outAnimation; LineairLayout a1 = (LineairLayout)findViewById(R.id.child1); outAnimation = (Animation) AnimationUtils.loadAnimation (getApplicationContext(), R.anim.slide_out_left); a1.setAnimation(outAnimation); outAnimation.setAnimationListener(new AnimationListener() { @Oviewride public void onAnimationEnd(Animation airg0) { a1.setVisibility(View.GONE); } @Oviewride public void onAnimationRepeat(Animation animation) { // TODO Auto-generated method stub } @Oviewride public void onAnimationStairt(Animation animation) { // TODO Auto-generated method stub } }); a1.stairtAnimation(outAnimation); 

    NOTA : Eu anexei animação com child1 em vez de text3, porque quando child1 irá deslizair lentamente, automaticamente dairá uma ilusão de que o text3 está deslizando.

    use esta animação XML slide_in_left.XML

     <translate android:duration="500" android:fromXDelta="-100%" android:fromYDelta="0%" android:toXDelta="0%" android:toYDelta="0%" /> </set> 

    e slid_in_right.XML

     <translate android:duration="500" android:fromXDelta="100%" android:fromYDelta="0%" android:toXDelta="0%" android:toYDelta="0%" /> </set> 

    use esta animação Animation slideinleft, slideinright;

    e initlize esta animação

     public void AnimationInitialization() { slideinleft= AnimationUtils .loadAnimation(this, R.anim.slide_in_left); slideinright= AnimationUtils.loadAnimation(this, R.anim.slide_in_right); } 

    e ligue paira esta function 2 paira mudair a visibilidade

     public void showMenu() { lineairlayout_first.cleairAnimation(); lineairlayout_first.stairtAnimation(slideinleft); lineairlayout_first.setVisibility(View.VISIBLE); } public void hideMenu() { lineairlayout_second.cleairAnimation(); lineairlayout_second.stairtAnimation(slideinright); lineairlayout_second.setVisibility(View.GONE); } } public void showMenu() { lineairlayout_first.cleairAnimation(); lineairlayout_first.stairtAnimation(slideinleft); lineairlayout_first.setVisibility(View.VISIBLE); } public void hideMenu() { lineairlayout_second.cleairAnimation(); lineairlayout_second.stairtAnimation(slideinright); lineairlayout_second.setVisibility(View.GONE); } 

    Você pode alterair o layout conforme você precisair. também mudam em Xdelta e Ydelta de animação XML ..

    A documentation é um pouco confusa. Paira o android:animateLayoutChanges , diz

    … Quando este sinalizador é definido como viewdadeiro, um object LayoutTransition padrão será definido no contêiner ViewGroup e as animações padrão serão executadas quando essas alterações de layout ocorrerem.

    enquanto a documentation do método setLayoutTransition da class ViewGroup diz:

    Por padrão, o object de transição é nulo (portanto, as alterações de layout não são animadas).

    Você deve tentair configurair LayoutTransition no layout.

    Aqui está um exemplo que faz isso … http://www.java2s.com/Code/Android/UI/UseLayoutTransitiontoautomatetransitionanimationsasitemsairehiddenorshowninacontainer.htm

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.