ImageView Tilt效果onTouch

时间:2013-11-06 06:41:31

标签: android android-imageview android-animation

我希望在用户触摸图像的ImageView上以x度显示倾斜(按下)效果。

任何想法我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:1)

试试这个..

    final ObjectAnimator forwardAnimator = ObjectAnimator.ofFloat(imageView,
            "RotationX", 0, 20f);
    forwardAnimator.setDuration(250);
    final ObjectAnimator backwardAnimator = ObjectAnimator.ofFloat(imageView,
            "RotationX", 20f, 0f);
    backwardAnimator.setStartDelay(250);
    backwardAnimator.setDuration(250);
    imageView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            forwardAnimator.start();
            backwardAnimator.start();
        }
    });

此请求API级别11 ...因为ObjectAnimator支持Api级别11