画像ボタンのアニメーションを設定しました。私が期待しているのは、フェードアウトしてから次のアクティビティを開始することです。
これは起こっていることではありません。
次のアクティビティを開始し、「戻る」を押すと、アニメーションはまだ「実行中」であり、フェードアウトを終了します。XMLでアニメーションを長時間設定する、アニメーションをスレッドに入れる、スレッドを使用してスリープする、アニメーションをスリープスレッドに入れるなど、さまざまな組み合わせを試しました。次のアクティビティが開始される前に、まだアニメーションが完了していません。
どんな助けでも大歓迎です!
フェードアウト用のXML:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.1"
android:duration="1000"
/>
</set>
androidのコード:(imageButtonのonClick用)
public void onClick(View v) {
Intent intent = new Intent(Current.this, Next.class);
v.startAnimation(animationFadeOut);
try {
Thread.sleep(1200);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
startActivity(intent);
}