正在尝试使用xamarin的Android(非xamarin还将帮助)的Android怎么做滑动对角线影响使用拖放
我希望用户能够拖动绿色部分做对角线拖动使用(见图片)他手指拖动它必须是对角线(它开始于喜欢红色的部分开始) image
我肠道滑动部分,到目前为止,但我不知道该怎么做对角线滑动部分
private float _viewX;
private int _originalLeft;
private int _originalRight;
private View _greenView;
private View _redView;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.QuestionsView);
_greenView = FindViewById<View>(Resource.Id.greenTrueView);
_redView = FindViewById<View>(Resource.Id.redFalseView);
_greenView.SetOnTouchListener(this);
_redView.SetOnTouchListener(this);
}
public bool OnTouch(View v, MotionEvent e)
{
if (v.Equals(_greenView))
{
switch (e.Action)
{
case MotionEventActions.Down:
_viewX = e.GetX();
_originalLeft = v.Left;
break;
case MotionEventActions.Move:
var left = (int)(e.RawX - _viewX);
v.Layout(left, v.Top, v.Right, v.Bottom);
break;
}
}
else
{
switch (e.Action)
{
case MotionEventActions.Down:
_viewX = e.GetX();
_originalRight = v.Right;
break;
case MotionEventActions.Move:
var right = (int)(_viewX + e.RawX);
v.Layout(v.Left, v.Top, right, v.Bottom);
break;
}
}
return true;
}
能否请您发布一些代码,显示你有什么到目前为止已经试过? –
嗨@ ElvisXia-MSFT,用当前代码编辑我有 –