0

画面の特定のXY位置からの平行移動アニメーションによってレイアウトをアニメーション化したいと思います。そしてこれは非常に正しく起こっています。これで、アニメーションがレイアウトを完了したときに問題が発生し、画面の上部の右隅に移動します。アニメーションが終了するのと同じ位置にレイアウトを維持したい。

 AnimationListener animationListener = new AnimationListener() {

        @Override
        public void onAnimationEnd(Animation arg0) {
            drawer_layout.setVisibility(View.VISIBLE);

        }

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

        }

        @Override
        public void onAnimationStart(Animation animation) {
            drawer_layout.setVisibility(View.VISIBLE);

        }

    };

    final Animation animTranslate = AnimationUtils.loadAnimation(this,
            R.anim.top_to_bottom_in);

    animTranslate.setAnimationListener(animationListener);

    drawer_layout = (LinearLayout) findViewById(R.id.drawer_layout);
    button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // bitmapBackground = CaptureBackground();

            faded_layout.setBackgroundColor(Color.parseColor("#50ffffff"));

            // HandleDropAnimation(drawer_layout);
            drawer_layout.startAnimation(animTranslate);
        }
    });

これが私のxmlです。

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromYDelta="25%p"
android:toYDelta="50%p" />
4

2 に答える 2

2

電話

animTranslate.setFillAfter(true);

アニメを始める前に。Java docsによると:

fillAfter が true の場合、このアニメーションが実行した変換は、終了後も保持されます。

于 2012-10-19T09:44:17.227 に答える
1

アニメーション開始前に使用

animTranslate.setFillAfter(true);
于 2012-10-19T09:51:52.370 に答える