1

Below code rotates clockwise when touched. What I want is to detect the user interaction with the layout and rotate accordingly.

relative.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if(event.getAction() == MotionEvent.ACTION_DOWN){
                relative.animate().rotationBy(60).setDuration(300).start();
            }else if(event.getAction() == MotionEvent.ACTION_UP){
                relative.animate().rotationBy(0).setDuration(10).start();
            }
            return true;
        }
    });

Without using animation stuff, using animations some functions like onClick events don't work properly on the layout.

johnrao07
  • 6,690
  • 4
  • 32
  • 55

1 Answers1

1

if you want to check about roation issues just go through this and in Sensor Events

Aditya Vyas-Lakhan
  • 13,409
  • 16
  • 61
  • 96
  • it's not about orientation , it's about rotation – johnrao07 Oct 15 '15 at 06:48
  • thats not what i looking for, you've given about sensor of device rotation, I am talking about just a relative layout which rotates on onTouch event – johnrao07 Oct 15 '15 at 07:10
  • so when it roatates as you mentioned you want to detect..so definately it is the issue related potrait and landscape..and what else you want to detect? – Aditya Vyas-Lakhan Oct 15 '15 at 07:28
  • take a look at this page http://code.tutsplus.com/tutorials/android-sdk-creating-a-rotating-dialer--mobile-8868, I implemented this to rotate but onClick events are not working. That's the reason why I am rotating a layout, so to work with OnClick events. I am able with clockwise rotation but couldn't with anticlickwise and clockwise both together – johnrao07 Oct 15 '15 at 07:34
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/92357/discussion-between-lakhan-and-johnrao07). – Aditya Vyas-Lakhan Oct 15 '15 at 07:39