title: Moving an ImageView located in a WindowManager doesn't work properly
body: <p>I'm trying to draw an Icon over everything on the screen (TOP MOST) similar to the chathead of new Facebook messenger</p>
  
  <p>I have create a service to work in the background and based on a specific condition my icon should appear on the screen (exactly like when someone sends you a message on facebook the messenger service will hook the message and shows the chathead on the screen to notify you about the new message)</p>
  
  <p><strong>What I did:</strong></p>
  
  <p>I have created the service and gave it the permission to show system alert windows (since the head is actually a system alert window)</p>
  
  <pre><code>[assembly: UsesPermission(Name = Android.Manifest.Permission.SystemAlertWindow)]
  </code></pre>
  
  <p>I have inherited a class (StickyHeadView) from ImageView and implemented OnTouchListener listener using the following way :</p>
  
  <pre><code>class StickyHeadView : ImageView, Android.Views.View.IOnTouchListener
  {
      private StickyHeadService OwnerService;
  
      public StickyHeadView(StickyHeadService ContextService, Context context)
          : base(context)
      {
          OwnerService = ContextService;
          SetOnTouchListener(this);
      }
  
      float TouchMoveX;
      float TouchMoveY;
  
      public bool OnTouch(View v, MotionEvent e)
      {
          var windowService = OwnerService.GetSystemService(Android.Content.Context.WindowService);
          var windowManager = windowService.JavaCast&lt;Android.Views.IWindowManager&gt;();
  
          switch (e.Action &amp; e.ActionMasked)
          {
              case MotionEventActions.Move:
                  TouchMoveX = (int)e.GetX();
                  TouchMoveY = (int)e.GetY();
                  OwnerService.LOParams.X = (int)(TouchMoveX);
                  OwnerService.LOParams.Y = (int)(TouchMoveY);
                  windowManager.UpdateViewLayout(this, OwnerService.LOParams);                    
                  Log.Debug("Point : ", "X: " + Convert.ToString(OwnerService.LOParams.X) + " Y: " + Convert.ToString(OwnerService.LOParams.Y));
                  return true;                    
              case MotionEventActions.Down:
                  return true;                    
              case MotionEventActions.Up:
                  return true;
          }
          return false;
      }
  }    
  </code></pre>
  
  <p>The service has wiindow manager to show the Icon on it...in Service "OnStart" event I initialize the Head :</p>
  
  <pre><code>        private StickyHeadView MyHead;
          public Android.Views.WindowManagerLayoutParams LOParams;
          public override void OnStart(Android.Content.Intent intent, int startId)
          {
              base.OnStart(intent, startId);
  
              var windowService = this.GetSystemService(Android.Content.Context.WindowService);
              var windowManager = windowService.JavaCast&lt;Android.Views.IWindowManager&gt;();
  
              MyHead = new StickyHeadView(this, this);
              MyHead.SetImageResource(Resource.Drawable.Icon);
              LOParams = new Android.Views.WindowManagerLayoutParams(Android.Views.WindowManagerLayoutParams.WrapContent,
                                  Android.Views.WindowManagerLayoutParams.WrapContent,
                                  Android.Views.WindowManagerTypes.Phone,
                                  Android.Views.WindowManagerFlags.NotFocusable,
                                  Android.Graphics.Format.Translucent);
  
              LOParams.Gravity = GravityFlags.Top | GravityFlags.Left;
              LOParams.X = 10;
              LOParams.Y = 10;
              windowManager.AddView(MyHead, LOParams);
          } 
  </code></pre>
  
  <p>as you can see I have declared a WindowManager and added the view (MyHead) to it with special parameters</p>
  
  <p><strong>My Problem :</strong></p>
  
  <p>When ever I try to move the View (My head) it doesn't move in a stable way and keeps having a quake! </p>
  
  <p>I'm testing it using android 4.0.4 on real HTC Phone</p>
  
  <p>I'm using monodroid</p>
  
  <p>Please help...if the implementation of the touch is not right please suggest a better way...thank you.</p>