Android ImageView Animation

前端 未结 9 1056
忘掉有多难
忘掉有多难 2020-12-04 07:32

I\'ve created a layout with an image view and a web view. The web view is set to have a default visibility of gone. When the activity fires up it displays the image view fir

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-04 08:24

    I have found out, that if you use the .getWidth/2 etc... that it won't work you need to get the number of pixels the image is and divide it by 2 yourself and then just type in the number for the last 2 arguments.

    so say your image was a 120 pixel by 120 pixel square, ur x and y would equal 60 pixels. so in your code, you would right:

    RotateAnimation anim = new RotateAnimation(0f, 350f, 60f, 60f);
    anim.setInterpolator(new LinearInterpolator());
    anim.setRepeatCount(Animation.INFINITE);
    anim.setDuration(700);
    

    and now your image will pivot round its center.

提交回复
热议问题