protected override void OnElementChanged(ElementChangedEventArgs <ListView> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                ViewCompat.SetNestedScrollingEnabled(Control, true);
            }
        }
        public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Bundle savedInstanceState)
        {
            var root = inflater.Inflate(Resource.Layout.fragment_card, container, false);
            var text = root.FindViewById <TextView> (Resource.Id.textView);

            text.Text = "Card: " + position;
            ViewCompat.SetElevation(root, 50);
            return(root);
        }
        protected virtual void SetBackgroundColor(BottomNavigationView bottomView, Color color)
        {
            var    menuView                  = bottomView.GetChildAt(0) as BottomNavigationMenuView;
            var    oldBackground             = bottomView.Background;
            var    colorDrawable             = oldBackground as ColorDrawable;
            var    colorChangeRevealDrawable = oldBackground as ColorChangeRevealDrawable;
            AColor lastColor                 = colorChangeRevealDrawable?.EndColor ?? colorDrawable?.Color ?? Colors.Transparent.ToNative();
            AColor newColor;

            if (color == null)
            {
                newColor = ShellView.DefaultBottomNavigationViewBackgroundColor.ToNative();
            }
            else
            {
                newColor = color.ToNative();
            }

            if (menuView == null)
            {
                if (colorDrawable != null && lastColor == newColor)
                {
                    return;
                }

                if (lastColor != newColor || colorDrawable == null)
                {
                    // taken from android source code
                    var backgroundColor = new MaterialShapeDrawable();
                    backgroundColor.FillColor = ColorStateList.ValueOf(newColor);
                    backgroundColor.InitializeElevationOverlay(bottomView.Context);

                    ViewCompat.SetBackground(bottomView, backgroundColor);
                }
            }
            else
            {
                if (colorChangeRevealDrawable != null && lastColor == newColor)
                {
                    return;
                }

                var index = ((IShellItemController)_shellItem).GetItems().IndexOf(_shellItem.CurrentItem);
                var menu  = bottomView.Menu;
                index = Math.Min(index, menu.Size() - 1);

                var child = menuView.GetChildAt(index);
                if (child == null)
                {
                    return;
                }

                var touchPoint = new Point(child.Left + (child.Right - child.Left) / 2, child.Top + (child.Bottom - child.Top) / 2);

                ViewCompat.SetBackground(bottomView, new ColorChangeRevealDrawable(lastColor, newColor, touchPoint));
            }
        }
Esempio n. 4
0
        private void UpdateElevation()
        {
            var shadowFrame = (ShadowFrame)Element;

            Control.StateListAnimator = new Android.Animation.StateListAnimator();

            ViewCompat.SetElevation(this, shadowFrame.Elevation);
            ViewCompat.SetElevation(Control, shadowFrame.Elevation);
        }
        void IVisualElementRenderer.SetLabelFor(int?id)
        {
            if (_defaultLabelFor == null)
            {
                _defaultLabelFor = ViewCompat.GetLabelFor(this);
            }

            ViewCompat.SetLabelFor(this, (int)(id ?? _defaultLabelFor));
        }
Esempio n. 6
0
 partial void DisconnectingHandler(NativeView nativeView)
 {
     if (nativeView.IsAlive() &&
         ViewCompat.GetAccessibilityDelegate(nativeView) is MauiAccessibilityDelegateCompat ad)
     {
         ad.Handler = null;
         ViewCompat.SetAccessibilityDelegate(nativeView, null);
     }
 }
Esempio n. 7
0
 partial void DisconnectingHandler(NativeView?nativeView)
 {
     if (nativeView.IsAlive() && AccessibilityDelegate != null)
     {
         AccessibilityDelegate.Handler = null;
         ViewCompat.SetAccessibilityDelegate(nativeView, null);
         AccessibilityDelegate = null;
     }
 }
Esempio n. 8
0
 public void SetOnViewAttachListener(OnViewAttachListener listener)
 {
     this.listener?.OnDetach();
     this.listener = listener;
     if (ViewCompat.IsAttachedToWindow(view))
     {
         listener?.OnAttach();
     }
 }
Esempio n. 9
0
 /// <summary>
 /// Hides the badge with a neat little scale animation.
 /// </summary>
 public void Hide(bool animated = true)
 {
     IsVisible = false;
     ViewCompat.Animate(this)
     .SetDuration(animated ? _animationDuration : 0)
     .ScaleX(0)
     .ScaleY(0)
     .Start();
 }
        private void UpdateElevation()
        {
            // we need to reset the StateListAnimator to override the setting of Elevation on touch down and release.
            Control.StateListAnimator = new Android.Animation.StateListAnimator();

            // set the elevation manually
            ViewCompat.SetElevation(this, MaterialFrame.Elevation);
            ViewCompat.SetElevation(Control, MaterialFrame.Elevation);
        }
Esempio n. 11
0
        public void SetLabelFor(int?id)
        {
            if (_defaultLabelFor == null)
            {
                _defaultLabelFor = ViewCompat.GetLabelFor(this);
            }

            ViewCompat.SetLabelFor(this, (int)(id ?? _defaultLabelFor));
        }
        /**
         * Sets the state of the bottom sheet. The bottom sheet will transition to that state with animation.
         *
         * @param state One of {@link #STATE_COLLAPSED}, {@link #STATE_ANCHOR_POINT}, {@link #STATE_EXPANDED} or {@link #STATE_HIDDEN}.
         */
        public void SetState(int state)
        {
            if (state == _state)
            {
                return;
            }

            /**
             * New behavior (added: state == STATE_ANCHOR_POINT ||)
             */
            if (state == StateCollapsed || state == StateExpanded || state == StateAnchorPoint || (Hideable && state == StateHidden))
            {
                _state           = state;
                _lastStableState = state;
            }

            View child = null;

            if (_viewRef == null)
            {
                _viewRef.TryGetTarget(out child);
            }
            if (child == null)
            {
                return;
            }

            int top;

            if (state == StateCollapsed)
            {
                top = _maxOffset;
            }
            else if (state == StateAnchorPoint)
            {
                top = AnchorPoint;
            }
            else if (state == StateExpanded)
            {
                top = _minOffset;
            }
            else if (Hideable && state == StateHidden)
            {
                top = _parentHeight;
            }
            else
            {
                throw new IllegalArgumentException("Illegal state argument: " + state);
            }

            SetStateInternal(StateSettling);
            if (_viewDragHelper.SmoothSlideViewTo(child, child.Left, top))
            {
                ViewCompat.PostOnAnimation(child, new SettleRunnable(this, child, state));
            }
        }
        private void CalculateLayout(int width, int height)
        {
            rectView.Reset();
            rectView.AddRect(0f, 0f, 1f * Width, 1f * Height, Path.Direction.Cw);

            if (clipManager != null)
            {
                if (width > 0 && height > 0)
                {
                    clipManager.SetupClipLayout(width, height);
                    clipPath.Reset();
                    clipPath.Set(clipManager.CreateMask(width, height));

                    if (RequiresBitmap())
                    {
                        if (clipBitmap != null)
                        {
                            clipBitmap.Recycle();
                        }
                        clipBitmap = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888);
                        Canvas canvas = new Canvas(clipBitmap);

                        if (drawable != null)
                        {
                            drawable.SetBounds(0, 0, width, height);
                            drawable.Draw(canvas);
                        }
                        else
                        {
                            canvas.DrawPath(clipPath, clipManager.GetPaint());
                        }
                    }

                    //invert the path for android P
                    if (Build.VERSION.SdkInt > BuildVersionCodes.OMr1)
                    {
                        bool success = rectView.InvokeOp(clipPath, Path.Op.Difference);
                    }

                    //this needs to be fixed for 25.4.0
                    if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop && ViewCompat.GetElevation(this) > 0f)
                    {
                        try
                        {
                            OutlineProvider = new CustomOutlineProvider(clipManager);
                        }
                        catch
                        {
                            //
                        }
                    }
                }
            }

            PostInvalidate();
        }
Esempio n. 14
0
            public override bool CanChildScrollUp()
            {
                var listView = listFragment.ListView;

                if (listView != null && listView.Visibility == ViewStates.Visible)
                {
                    return(ViewCompat.CanScrollVertically(listView, -1));
                }
                return(false);
            }
Esempio n. 15
0
        partial void EnsureClip(Rect rect)
        {
            if (rect.IsEmpty)
            {
                ViewCompat.SetClipBounds(this, null);
                return;
            }

            ViewCompat.SetClipBounds(this, rect.LogicalToPhysicalPixels());
        }
Esempio n. 16
0
 public override void onAnimationEnd(View view)
 {
     newViewAnimation.Listener = null;
     ViewCompat.setAlpha(newView, 1);
     ViewCompat.setTranslationX(newView, 0);
     ViewCompat.setTranslationY(newView, 0);
     dispatchChangeFinished(changeInfo.newHolder, false);
     outerInstance.mChangeAnimations.Remove(changeInfo.newHolder);
     outerInstance.dispatchFinishedWhenDone();
 }
Esempio n. 17
0
        private void UpdateElevation()
        {
            var materialFrame = (MidgeFrame)Element;

            // we need to reset the StateListAnimator to override the setting of Elevation on touch down and release.
            Control.StateListAnimator = new Android.Animation.StateListAnimator();

            ViewCompat.SetElevation(this, materialFrame.Elevation);
            ViewCompat.SetElevation(Control, materialFrame.Elevation);
        }
Esempio n. 18
0
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);
            recyclerView = view.FindViewById <RecyclerView>(Resource.Id.recycler_view_challenge);
            var layoutManager = new StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.Vertical);

            recyclerView.SetLayoutManager(layoutManager);
            recyclerView.HasFixedSize = false;
            ViewCompat.SetNestedScrollingEnabled(recyclerView, false);
        }
Esempio n. 19
0
 private void OnItemClick()
 {
     if (state.IsEditMode)
     {
         ToogleCheckbox(state.IsChecked);
         return;
     }
     ViewCompat.SetTransitionName(imageView, Resources.GetString(Resource.String.transition_goal_image));
     command.ItemClickListener(state.Id, imageView, HexConverter(currentPalette));
 }
Esempio n. 20
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            TextView toolbar_title = (TextView)Activity.FindViewById(Resource.Id.toolbar_title);

            Activity.Title = "";
            view           = inflater.Inflate(Resource.Layout.WeClipsFragment, container, false);
            gvWeClip       = view.FindViewById <GridView>(Resource.Id.gvWeClip);
            ViewCompat.SetNestedScrollingEnabled(gvWeClip, true);
            return(view);
        }
Esempio n. 21
0
        public void OnTransitionStart(Transition transition)
        {
            if (isStarting)
            {
                isStarting = false;

                ViewCompat.SetTransitionName(headerImage, null);
                ViewCompat.SetTransitionName(recyclerView, null);
            }
        }
 private void Show(FloatingActionButton button)
 {
     _isShow = true;
     ViewCompat.Animate(button).ScaleX(1.0F).ScaleY(1.0F).Alpha(1.0F)
     .SetInterpolator(new FastOutLinearInInterpolator()).WithLayer().SetListener(null)
     .WithStartAction(new Runnable(() =>
     {
         button.Visibility = ViewStates.Visible;
     }));
 }
Esempio n. 23
0
        private void initRecyclerView()
        {
            _rvUsers = _view.FindViewById <RecyclerView>(Resource.Id.rvUsers);
            var layoutManager = new LinearLayoutManager(_activity);

            _rvUsers.SetLayoutManager(layoutManager);
            _userScoreAdapter = new UserScoreAdapter(_viewModel.CurrentGame, this);
            _rvUsers.SetAdapter(_userScoreAdapter);
            ViewCompat.SetNestedScrollingEnabled(_rvUsers, false);
        }
Esempio n. 24
0
 /// <summary>
 /// Apply elevation on the views for API 21+ devices.
 /// </summary>
 /// <param name="elevation">Size of the elevation.</param>
 /// <param name="views">Views on which the elevation is to be applied.</param>
 public static void SetElevation(float elevation, params View[] views)
 {
     foreach (View view in views)
     {
         if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
         {
             ViewCompat.SetElevation(view, elevation);
         }
     }
 }
Esempio n. 25
0
        private View FindViewUnder()
        {
            int count = this.GetAdapter().ItemCount;

            for (int i = count - 1; i >= 0; i--)
            {
                View child = GetChildAt(i);
                if (child == null)
                {
                    continue;
                }

                Region r = null;
                if (((LinearLayoutManager)GetLayoutManager()).Orientation == LinearLayoutManager.Horizontal)
                {
                    float translationX = ViewCompat.GetTranslationX(child);
                    r = new Region(
                        new Rect(
                            (int)(child.Left + translationX),
                            hoverCellCurrentBounds.Top,
                            (int)(child.Right + translationX),
                            hoverCellCurrentBounds.Bottom));
                }
                else
                {
                    float translationY = ViewCompat.GetTranslationY(child);
                    r = new Region(
                        new Rect(
                            hoverCellCurrentBounds.Left,
                            (int)(child.Top + translationY),
                            hoverCellCurrentBounds.Right,
                            (int)(child.Bottom + translationY)));
                }

                r.InvokeOp(hoverCellCurrentBounds, Region.Op.Intersect);

                if (!r.IsEmpty)
                {
                    var ratio = (float)(r.Bounds.Width() * r.Bounds.Height())
                                / (float)(hoverCellCurrentBounds.Width() * hoverCellCurrentBounds.Height());
                    LogHelper.Debug(TAG, string.Format("#{0}# is overlapped, ratio = {1}", (char)GetChildItemId(child), ratio));
                    if (ratio > 0.5)
                    {
                        if (GetChildItemId(child) == mobileItemId)
                        {
                            return(null);
                        }

                        LogHelper.Debug(TAG, string.Format("Swap with: {0}", (char)GetChildItemId(child)));
                        return(child);
                    }
                }
            }
            return(null);
        }
Esempio n. 26
0
 private void InstallAccessibilityDelegate()
 {
     // The accessibility delegate enables customizing accessibility behavior
     // via composition as opposed as inheritance. The main benefit is that
     // one can write a backwards compatible application by setting the delegate
     // only if the API level is high enough i.e. the delegate is part of the APIs.
     // The easiest way to achieve that is by using the support library which
     // takes the burden of checking API version and knowing which API version
     // introduced the delegate off the developer.
     ViewCompat.SetAccessibilityDelegate(this, new MyAccessibilityDelegateCompat());
 }
        public static bool HitTest(this View v, int x, int y)
        {
            var tx     = (int)(ViewCompat.GetTranslationX(v) + 0.5f);
            var ty     = (int)(ViewCompat.GetTranslationY(v) + 0.5f);
            var left   = v.Left + tx;
            var right  = v.Right + tx;
            var top    = v.Top + ty;
            var bottom = v.Bottom + ty;

            return(x >= left && x <= right && y >= top && y <= bottom);
        }
Esempio n. 28
0
        public static void UpdateSemantics(this View platformView, IView view)
        {
            var semantics = view.Semantics;

            if (semantics == null)
            {
                return;
            }

            ViewCompat.SetAccessibilityHeading(platformView, semantics.IsHeading);
        }
 /// <param name="e"></param>
 protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     base.OnElementPropertyChanged(sender, e);
     if (e.PropertyName == "Elevation")
     {
         var materialButton = (MaterialButton)Element;
         ViewCompat.SetElevation(this, materialButton.Elevation);
         ViewCompat.SetElevation(Control, materialButton.Elevation);
         UpdateLayout();
     }
 }
 private void Hide(FloatingActionButton button)
 {
     _isShow = false;
     ViewCompat.Animate(button).ScaleX(0F).ScaleY(0F).Alpha(1.0F)
     .SetInterpolator(new FastOutSlowInInterpolator()).WithLayer().SetListener(null)
     .WithStartAction(new AnimationDrawable())
     .WithEndAction(new Runnable(() =>
     {
         button.Visibility = ViewStates.Invisible;
     }));
 }