I want to change layouts using TranslateAnimation
.
My XML is like
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/buttonsld"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/textsld"
android:text="slideup" />
<LinearLayout
android:id="@+id/layoutsld2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/buttonsld2"
android:layout_below="@+id/buttonsld"
android:background="@drawable/iz"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="@+id/layoutsld3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/buttonsld2"
android:layout_below="@+id/buttonsld"
android:background="@drawable/fon"
android:orientation="vertical"
android:visibility="gone" >
</LinearLayout>
<Button
android:id="@+id/buttonsld2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="slidedown" />
</RelativeLayout>
and my code is like
private int x= 0;
buttonslideup.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (x == 0) {
lin_lay2.setVisibility(View.GONE);
lin_lay3.setVisibility(View.VISIBLE);
Animation slide = new TranslateAnimation(0, 0, 100, 0);
slide.setDuration(1000);
slide.setFillAfter(true);
lin_lay3.startAnimation(slide);
x = 1;
} else {
lin_lay3.setVisibility(View.GONE);
lin_lay2.setVisibility(View.VISIBLE);
Animation slide = new TranslateAnimation(0, 0,
100, 0);
slide.setDuration(1000);
slide.setFillAfter(true);
lin_lay2.startAnimation(slide);
x = 0;
}
}
});
but when I use this, at first, the lin_lay3
slides and comes to screen and there is no problem, but when I click to button again, lin_lay2
slides, but it is behind lin_lay3
and I cannot see lin_lay2
.
What I want is to change these layouts
with the click of the button
.