简体   繁体   中英

Text Animation Android Z index

I am making a logo quiz sort of app, for which on a correct answer I want the text/image to come from the Z axis to the screen, more like a 3d effect inwards. Then the text/image should move a little too, just like wiggle at its place. How do I go about?

Thanks in advance! :)

if(checkanswer.equalsIgnoreCase(jawab[0])||checkanswer.equalsIgnoreCase(jawab[1])||checkanswer.equalsIgnoreCase(jawab[2]))
            {
                answer.setBackgroundColor(Color.GREEN);
                check_answer.setText("CORRECT ANSWER !"); //Correct Answer should wiggle!
                answer.setEnabled(false);

                // Disable SUBMIT button
                submit.setClickable(false);

                // EDIT THE SCORES
                forScores=getSharedPreferences(FileName,0);
                editkar=forScores.edit();
                int score=forScores.getInt("Level "+receiver[1], 0);
                score++;
                editkar.putInt("Level "+receiver[1],score);
                editkar.commit(); }

You can the ObjectAnimator class introduced in 3.1 though there's NineOldAndroids library for usage on pre-3.1 platforms.

So first thing I do here is scale the view's X and Y axis and alpha from 0 to 1 in a set so they play together. Then when the animation ends, the wiggle animation starts. It basically moves left and right by 50 pixels. The rest is self explanatory.

AnimatorSet set = new AnimatorSet();
    set.playTogether(
            ObjectAnimator.ofFloat(mView, "alpha", 0, 1),
            ObjectAnimator.ofFloat(mView, "scaleX", 0,  1),
            ObjectAnimator.ofFloat(mView, "scaleY", 0, 1)
    );
    set.setDuration(1000).start();

    set.addListener(new AnimatorListener() {

        @Override
        public void onAnimationStart(Animator arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onAnimationRepeat(Animator arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onAnimationEnd(Animator arg0) {
            // TODO Auto-generated method stub
            ObjectAnimator.ofFloat(mView, "translationX", 0, 50, -50, 50, -50, 50, -50, 0).setDuration(1000).start();
        }

        @Override
        public void onAnimationCancel(Animator arg0) {
            // TODO Auto-generated method stub

        }
    });

尝试使用相机: http : //developer.android.com/reference/android/graphics/Camera.html ,有关如何使用它的一些教程,请参见

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM