cannt scroll imageview right and down

by Chenguo » Thu, 08 May 2008 00:53:55 GMT


Sponsored Links
 hi,everyone!
I add onTouchEvent method to ImageSwitcher of API Demo, and i'd like to scroll 
the image in this method.But the image cannt be scrolled right and down from 
its original place.The following is my code:

private float mx,my;
    @Override
    public boolean onTouchEvent(MotionEvent event)
    {
     ImageView switcherView = (ImageView)mSwitcher.getCurrentView();
     float curX,curY;
     switch(event.getAction())
     {
        case MotionEvent.ACTION_DOWN :
             mx = event.getX();
             my = event.getY();
             break;
       case MotionEvent.ACTION_MOVE :
             curX = event.getX();
             curY = event.getY();
             switcherView.scrollBy((int)(mx - curX),(int)(my - curY));
             mx = curX;
             my = curY;
             break;
        case MotionEvent.ACTION_UP :
             curX = event.getX();
             curY = event.getY();
             switcherView.scrollBy((int)(mx - curX),(int)(my - curY));
             break;
     }    
        return super.onTouchEvent(event);
    }
                                
--------------
Chenguo
2008-05-08



--~--~---------~--~----~------------~-------~--~----~



cannt scroll imageview right and down

by Megha Joshi » Thu, 08 May 2008 06:22:33 GMT


 Using the code that you provided, I can move the Image in any direction on
the screen.
So its working as you expected, isn't it?






--~--~---------~--~----~------------~-------~--~----~


Sponsored Links