0

私のAndroidアプリには、別のビューの上に配置されたビューがあります。ボタンをクリックすると、このトップビューがアニメーション化されて画面から消えます。問題は、すべてのタッチイベントをキャプチャし、背後にあるビューに渡されないため、ビューがまだ「そこにある」ように見えることです。

ビューをアニメーション化するコードは次のとおりです。

TranslateAnimation animation = new TranslateAnimation (0, 0, 0, height);
animation.setDuration(1000);
animation.setFillAfter(true);
topView.startAnimation(animation);

この問題を解決するにはどうすればよいですか?

4

1 に答える 1

1

アニメーション リスナーを作成し、アニメーションが終了したらビューを親から削除します。

Animation animation = new AlphaAnimation(0 ,0);
        animation.setAnimationListener(new AnimationListener() {

            public void onAnimationStart(Animation animation) {
                // TODO Auto-generated method stub

            }

            public void onAnimationRepeat(Animation animation) {
                // TODO Auto-generated method stub

            }

            public void onAnimationEnd(Animation animation) {
                parentView.removeView(topView)
            }
        });
于 2012-10-17T17:51:05.720 に答える