hello everyone. seek help! GestureOverlay's problem


Last Updated:

  1. BoneLee

    BoneLee New Member This Topic's Starter

    Joined:
    Nov 7, 2010
    Messages:
    2
    Likes Received:
    0
    Hello everybody. when I am in the development of android application about gesture,I encountered a problem.
    When I use GestureOverlay's function setGestureColor to change the gesture's color,but that does not work? I can only set the xml attributes "android: gestureColor" to change the gesture's stroke color!
    This is my code:
    GestureOverlayView overlay=(GestureOverlayView)findViewById(R.id.gestures_overlay);
    overlay.setBackgroundColor(Color.MAGENTA);//It works!!!
    overlay.setGestureColor(Color.BLUE);//Not work
    overlay.setGestureStrokeWidth(12);//It works
    Am I wrong? Because I want to dynamically change the color of gesture stroke, please help me, thanks a lot.
     

    Advertisement
  2. BoneLee

    BoneLee New Member This Topic's Starter

    Joined:
    Nov 7, 2010
    Messages:
    2
    Likes Received:
    0
    anyone knows?
     
  3. NightAngel79

    NightAngel79 Bounty Hunter Administrator Moderator

    Joined:
    May 11, 2010
    Messages:
    22,332
    Likes Received:
    7,598
    moved to developer section
     
  4. Smalfish

    Smalfish New Member

    Joined:
    Nov 8, 2010
    Messages:
    2
    Likes Received:
    0
  5. codelurker

    codelurker New Member

    Joined:
    Jan 20, 2011
    Messages:
    1
    Likes Received:
    0
    I've been having the same problem and I finally found the solution. If you look at the source code for GestureOverlayView, you'll notice a boolean test for mHandleGestureActions at line 559 (and others) that makes a call to [private void] setCurrentColor when drawing the gesture. Unfortunately mHandleGestureActions is only set when you use the OnGesturePerformedListener listener.

    This is a total hack; but it works:

    Create a stub view that implements the OnGesturePerformedListener and add that to your overlay's list of OnGesturePerformedListeners. You don't have to
    do anything with the listener; but it needs to be a separate view from the one you're using as the REAL listener (or you'll crash your app). Then add your
    OnGesturingListener or OnGestureListener view that does the REAL work.
     
  6. dogster

    dogster New Member

    Joined:
    Jan 27, 2011
    Messages:
    1
    Likes Received:
    0
    codelurker, thank you for your post. It helped me to solve the same problem with the gesture color, though I was able to add the OnGesturePerformedListener as another interface to my listener class and did not need to create a stubView as follows:

    class
    GesturesProcessor implements GestureOverlayView.OnGestureListener,

    OnGesturePerformedListener {
    }
     

Share This Page

Loading...