Android Studio 3D翻转动画无法解析符号

时间:2019-05-18 02:26:50

标签: android animation compiler-errors 3d android-animation

我正在尝试将此link上的第二个答案提供的代码用于3d翻转动画,但是此行中的“ frontView”和“ backView”得到了“无法解析符号” :

mFlipAnimator.addUpdateListener(new FlipListener(frontView, backView));

我不知道代码有什么问题,下面是活动的代码

公共类FullscreenActivity扩展了AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    overridePendingTransition(R.anim.fadein, R.anim.fadeout);
    setContentView(R.layout.activity_fullscreen);

    ValueAnimator mFlipAnimator;
    mFlipAnimator = ValueAnimator.ofFloat(0f, 1f);
    mFlipAnimator.addUpdateListener(new FlipListener(frontView, backView));

}
    public class FlipListener implements ValueAnimator.AnimatorUpdateListener {

        private final View mFrontView;
        private final View mBackView;
        private boolean mFlipped;

        public FlipListener(final View front, final View back) {
            this.mFrontView = front;
            this.mBackView = back;
            this.mBackView.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationUpdate(final ValueAnimator animation) {
            final float value = animation.getAnimatedFraction();
            final float scaleValue = 0.625f + (1.5f * (value - 0.5f) * (value - 0.5f));

            if(value <= 0.5f){
                this.mFrontView.setRotationY(180 * value);
                this.mFrontView.setScaleX(scaleValue);
                this.mFrontView.setScaleY(scaleValue);
                if(mFlipped){
                    setStateFlipped(false);
                }
            } else {
                this.mBackView.setRotationY(-180 * (1f- value));
                this.mBackView.setScaleX(scaleValue);
                this.mBackView.setScaleY(scaleValue);
                if(!mFlipped){
                    setStateFlipped(true);
                }
            }
        }

        private void setStateFlipped(boolean flipped) {
            mFlipped = flipped;
            this.mFrontView.setVisibility(flipped ? View.GONE : View.VISIBLE);
            this.mBackView.setVisibility(flipped ? View.VISIBLE : View.GONE);

谢谢!

0 个答案:

没有答案