Xamarin Android - Create a line where your finger goes

Asked

Viewed 83 times

3

Hello, I would like to create a straight or rectangular, where my finger goes. Actually, it doesn’t have to be exactly where you go, but on top of every button I pass the finger it will increase the rectangle, as if it were a selection of a word in a "word search". I have a GridLayout 15x15 and a button within each cell.

Imagem com Exemplo
I tried to put on onTouch of each button as below but did not give.

    public bool OnTouch(View v, MotionEvent e)
    {
        switch (e.Action)
        {
            case MotionEventActions.Down:
                _viewX = e.GetX();
                _viewY = e.GetY();
                break;
            case MotionEventActions.Move:
                var left = (int)(e.RawX - _viewX);
                var right = (int)(left + v.Width);

                break;
            case MotionEventActions.Up:
                Canvas c = new Canvas();
                c.DrawRect(new Rect((int)_viewX, (int)_viewY, (int)_viewX + 200, (int)_viewY + 200), new Paint() { Color = Color.Red });

                ((GirdLayout)v.Parent).Draw(c);
                break;
        }
        return true;
    }
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.