按下按钮时如何弹跳或缩放动画

时间:2018-09-29 06:05:09

标签: java android android-animation

我想在媒体上像这样动画。

enter image description here

我正在使用这个

 <scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="200"
android:fillAfter="true" 
android:fromXScale="0.9"
android:fromYScale="0.9"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1.0"
android:toYScale="1.0" >

 mBounceAnimation = AnimationUtils.loadAnimation(LoginActivity.this,R.anim.bounce);



       btnLogin.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    btnLogin.startAnimation(mBounceAnimation);
                    // start your first zoom out Animation here
                    break;

                case MotionEvent.ACTION_UP:
               // start zoom in animation which returns to original  state
                    btnLogin.clearAnimation();
                    break;
            }
            return false;
        }
    });

0 个答案:

没有答案