public void SetShape(AView view, IBackgroundShape newShape) { _nativeView = view; if (_shape != newShape) { if (_shape != null) { _shape.ShapeInvalidateRequested -= OnShapeInvalidateRequested; } if (newShape != null) { newShape.ShapeInvalidateRequested += OnShapeInvalidateRequested; } _shape = newShape; PathProvider?.Dispose(); PathProvider = PathProvidersContainer.Resolve(_shape.GetType()); if (PathProvider != null) { PathProvider.SetShape(newShape); _nativeView?.GetGradientDrawable()?.SetPathProvider(PathProvider); } } Invalidate(); }
public void Invalidate() { PathProvider?.Invalidate(); if (_nativeView != null) { _nativeView.OutlineProvider?.Dispose(); _nativeView.OutlineProvider = new PathOutlineProvider(PathProvider); _nativeView.ClipToOutline = true; _nativeView.PostInvalidate(); _nativeView.GetGradientDrawable()?.InvalidatePath(); _nativeView.GetGradientDrawable()?.InvalidateSelf(); var maskDrawable = _nativeView?.GetRippleMaskDrawable(); if (maskDrawable != null && PathProvider != null) { maskDrawable.Shape = new PathShape(PathProvider.Path, _nativeView.Width, _nativeView.Height); maskDrawable.InvalidateSelf(); } } }