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


Other Threads

1. Problem with updating sound in Widget

any1 knwng d answer??it wil be of great help.




-- 

2. How can I create an aircraft-mounted-liked compass?

I want to create a non-generic compass that uses rotating directions
instead of a rotating needle as in the conventional compass. The
drawing is like the illustration below.

                    |
' ' W ' ' ' ' ' N ' ' ' ' ' E ' ' ' ' ' S ' ' '

(shift a bit to the east)

                    |
' ' ' ' ' N ' ' ' ' ' E ' ' ' ' ' S ' ' ' ' ' W

The needle (depict as "|") is fixed and the direction string should
have
some sort of "rotation" effect that immediately relocates each sign or
character from one tip of the edge to the opposite edge. Of course,
the movement follows the reading of the Android sensor.

Does anyone has an idea how to implement this? I stumbled with how
I create the rotation effect and connect the string's movement with
the sensor reading.

Thanks
/Joe

-- 

3. Intent->Activity

4. Market Question

5. adjustResize with Landscape Mode.

6. ExpandableListView help

7. Application restarts on orientation change