コード例 #1
0
ファイル: BadgeView.cs プロジェクト: luinnx/android-2
        private void applyTo(View target)
        {
            Android.Views.ViewGroup.LayoutParams lp     = target.LayoutParameters;
            Android.Views.IViewParent            parent = target.Parent;
            FrameLayout container = new FrameLayout(context);

            if (target is TabWidget)
            {
                // set target to the relevant tab child container
                target      = ((TabWidget)target).GetChildTabViewAt(targetTabIndex);
                this.target = target;

                ((ViewGroup)target).AddView(container,
                                            new Android.Views.ViewGroup.LayoutParams(Android.Views.ViewGroup.LayoutParams.FillParent, Android.Views.ViewGroup.LayoutParams.FillParent));

                this.Visibility = (ViewStates.Gone);
                container.AddView(this);
            }
            else
            {
                // TODO verify that parent is indeed a ViewGroup
                ViewGroup group = (ViewGroup)parent;
                int       index = group.IndexOfChild(target);

                group.RemoveView(target);
                group.AddView(container, index, lp);

                container.AddView(target);

                this.Visibility = (ViewStates.Gone);
                container.AddView(this);

                group.Invalidate();
            }
        }
        protected override bool OnSetBottomView(ViewGroup viewGroup)
        {
            var editText = new EditText(this.Context);

            editText.SetMaxLines(this.Config.SingleLine ? 1 : 10);
            editText.SetSingleLine(this.Config.SingleLine);
            editText.Hint = this.Config.Placeholder;
            var lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);

            editText.LayoutParameters = lp;
            editText.TextChanged     += (s, e) =>
            {
                this.Config.Text = e.Text?.ToString();
            };

            viewGroup.AddView(editText);
            viewGroup.Invalidate();

            return(true);
        }
コード例 #3
0
        public bool OnTouch(Android.Views.View v, MotionEvent e)
        {
            var imageView    = (ImageView)v;
            var layoutParams = (ViewGroup.MarginLayoutParams)v.LayoutParameters;

            switch (e.Action)
            {
            case MotionEventActions.Move:
                int x_cord = (int)e.RawX;

                if (!CheckCollision(imageView, x_cord))
                {
                    MoveArrows(imageView, x_cord);
                }
                break;
            }

            mRootLayout.Invalidate();
            return(true);
        }
コード例 #4
0
            private void ApplyTo(View target)
            {
                var         lp        = target.LayoutParameters;
                IViewParent parent    = target.Parent;
                FrameLayout container = new FrameLayout(context);

                // borrow some properties from the view which the badge is being applied
                this.Clickable            = target.Clickable;
                this.Focusable            = target.Focusable;
                this.FocusableInTouchMode = target.FocusableInTouchMode;

                if (target is TabWidget)
                {
                    target      = ((TabWidget)target).GetChildTabViewAt(targetTabIndex);
                    this.target = target;

                    ((ViewGroup)target).AddView(
                        container,
                        new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent)
                        );

                    Visibility = ViewStates.Gone;
                    container.AddView(this);
                }
                else
                {
                    ViewGroup group = (ViewGroup)parent;                        // will throw an exception if not actually a ViewGroup
                    int       index = group.IndexOfChild(target);

                    group.RemoveView(target);
                    group.AddView(container, index, lp);

                    container.AddView(target);

                    Visibility = ViewStates.Gone;
                    container.AddView(this);

                    group.Invalidate();
                }
            }
コード例 #5
0
ファイル: MainActivity.cs プロジェクト: acmaarts/Rev-Trainer
        bool View.IOnTouchListener.OnTouch(View v, MotionEvent e)
        {
            RelativeLayout.LayoutParams layoutParams;
            int rawX = (int)e.RawX;
            int rawY = (int)e.RawY;

            switch (e.Action & MotionEventActions.Mask)
            {
            case MotionEventActions.Down:
                layoutParams = v.LayoutParameters as RelativeLayout.LayoutParams;
                _oldX        = rawX - layoutParams.LeftMargin;
                _oldY        = rawY - layoutParams.TopMargin;

                _oldRawX = rawX;
                _oldRawY = rawY;
                break;

            case MotionEventActions.Up:
                var rawXDelta = Math.Abs(rawX - _oldRawX);
                var rawYDelta = Math.Abs(rawY - _oldRawY);

                if (rawXDelta < 15 && rawYDelta < 15)
                {
                    if (_viewModel.IsTurningClockwise)
                    {
                        v.Rotation += 45.0f;
                    }
                    else
                    {
                        v.Rotation -= 45.0f;
                    }

                    _viewModel.RotateKite((int)v.Tag);
                }
                break;

            case MotionEventActions.PointerDown:
                break;

            case MotionEventActions.PointerUp:
                break;

            case MotionEventActions.Move:
                var xDelta = rawX - _oldX;
                var yDelta = rawY - _oldY;

                layoutParams            = v.LayoutParameters as RelativeLayout.LayoutParams;
                layoutParams.LeftMargin = xDelta;
                layoutParams.TopMargin  = yDelta;
                v.LayoutParameters      = layoutParams;

                _viewModel.MoveKite((int)v.Tag, new Position
                {
                    X = v.GetX(),
                    Y = v.GetY()
                });
                break;
            }

            _drawView.UpdateTeam(_viewModel.Team);
            _root.Invalidate();
            _drawView.Invalidate();
            return(true);
        }