を使ってレイアウトを変更したいTranslateAnimation
。
私のXMLは
<?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>
私のコードは次のようなものです
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;
}
}
});
ですが、これを使ってみると、最初はlin_lay3
スライドして画面に出てきて問題ないのですが、再度ボタンをクリックするとlin_lay2
スライドするのですが、後ろにずれてlin_lay3
見えませんlin_lay2
。
私が望むのはlayouts
、 をクリックしてこれらを変更することbutton
です。