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?
On Wed, May 7, 2008 at 5:53 PM, Chenguo <[EMAIL PROTECTED]> wrote: > > 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 > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---