我正在使用 Mono-For-Droid。我有一个ImageView
并且想要移动它以在我触摸它时跟随我的手指并在我松开手指时停止移动。
这是我的代码,请指教怎么做?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Util;
using Android.Graphics.Drawables;
using Android.Content.Res;
[assembly: UsesPermission(Name = Android.Manifest.Permission.SystemAlertWindow)]
namespace ExtremeKeyboard
{
[Service]
public class ChatheadService: Android.App.Service
{
System.Threading.Timer _timer;
private IWindowManager windowManager;
private ImageView ReminderHead;
private Drawable icon;
private 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<Android.Views.IWindowManager>();
ReminderHead = new ImageView(this);
ReminderHead.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 = 0;
LOParams.Y = 100;
windowManager.AddView(ReminderHead, LOParams);
}
public override Android.OS.IBinder OnBind(Android.Content.Intent intent)
{
throw new NotImplementedException();
}
}
}