示例#1
0
        protected override void OnAttached()
        {
            // Gesture touches
            gesture                  = new GestureTouchSam(this, null, View);
            View.TouchDelegate       = gesture;
            View.Clickable           = true;
            View.LongClickable       = true;
            View.SoundEffectsEnabled = true;

            // Animation tap
            overlayAnimation = new FrameLayout(Container.Context)
            {
                LayoutParameters = new ViewGroup.LayoutParams(-1, -1),
                Clickable        = false,
                Focusable        = false,
            };

            Container.AddView(overlayAnimation);
            Container.LayoutChange += OnViewLayoutChanged;
            overlayAnimation.BringToFront();

            if (IsSdk21)
            {
                tapColor = Touch.GetColor(Element).ToAndroid();
                overlayAnimation.Background = CreateRipple(tapColor);
            }

            // Updates
            UpdateAnimationColor();
            UpdateLongTapCommand();
            UpdateLongTapLatency();
        }
示例#2
0
        private void UpdateAnimationColor()
        {
            var color = Touch.GetColor(Element);

            if (color == Xamarin.Forms.Color.Default)
            {
                return;
            }

            tapColor      = color.ToAndroid();
            tapColorAlpha = (tapColor.A == 255) ? (byte)80 : tapColor.A;

            if (IsSdk21)
            {
                ripple.SetColor(GetRippleColorSelector(tapColor));
            }
        }
示例#3
0
        private void SetEffectColor()
        {
            var color = Touch.GetColor(Element);

            if (color == Xamarin.Forms.Color.Default)
            {
                return;
            }

            this.color = color.ToAndroid();
            alpha      = this.color.A == 255 ? (byte)80 : this.color.A;

            if (EnableRipple)
            {
                ripple.SetColor(GetPressedColorSelector(this.color));
            }
        }
示例#4
0
        private void UpdateEffectColor()
        {
            _layer?.Dispose();
            _layer = null;

            var color = Touch.GetColor(Element);

            if (color == Color.Default)
            {
                return;
            }
            _alpha = color.A < 1.0 ? 1 : 0.3;

            _layer = new UIView
            {
                BackgroundColor        = color.ToUIColor(),
                UserInteractionEnabled = false,
            };
        }