N
N
Nikolarsen2018-03-22 09:39:09
Java
Nikolarsen, 2018-03-22 09:39:09

How to rotate imageview by moving?

Hello. The question is ...
There is a code ...

ImageView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent event) {
          switch (event.getAction()) {

            case MotionEvent.ACTION_DOWN:
              dX = view.getX() - event.getRawX();
              dY = view.getY() - event.getRawY();
              break;

            case MotionEvent.ACTION_MOVE:
              view.animate()
                .x(event.getRawX() + dX)
                .y(event.getRawY() + dY)
                .setDuration(0)
                .start();                     
              break;
            case MotionEvent.ACTION_UP:
              break;
            default:
              return false;
          }
          return true;
        }
      });

I press lead and imageview moves after the finger. How to make the imageview rotate around its axis instead of moving... With animation, it's a bit tight for now. Can you explain? You are welcome !! I want to figure it out...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question