void DrawHighlightOnView(VisualElement element) { var view = Platform.GetRenderer(element).View; highlightedView = view; highlightedViewOriginalBackground = highlightedView.Background; var gd = new GradientDrawable(); gd.SetColor(AndroidColor.Red.ToArgb()); gd.SetAlpha(255 / 2); Drawable highlightedBackground; if (highlightedViewOriginalBackground == null) { highlightedBackground = gd; } else { highlightedBackground = new LayerDrawable(new [] { highlightedViewOriginalBackground, gd }); } #pragma warning disable CS0618 // Type or member is obsolete highlightedView.SetBackgroundDrawable(highlightedBackground); #pragma warning restore CS0618 // Type or member is obsolete }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (Element == null) { return; } var z = (MyEntry)this.Element; if (e.PropertyName != MyEntry.BorderStyleProperty.PropertyName) { return; } var gradientDrawable = new GradientDrawable(); gradientDrawable.SetCornerRadius(60f); gradientDrawable.SetStroke(8, z.BorderColor.ToAndroid()); gradientDrawable.SetColor(Color.LightGray); gradientDrawable.SetAlpha(100); Control.SetBackground(gradientDrawable); Control.SetPadding(50, Control.PaddingTop, Control.PaddingRight, Control.PaddingBottom); }
protected override void OnElementChanged(ElementChangedEventArgs <Picker> e) { base.OnElementChanged(e); if (e.OldElement == null) { // Properties to custom picker GradientDrawable gradientDrawable = new GradientDrawable(); gradientDrawable.SetCornerRadius(10f); gradientDrawable.SetColor(Android.Graphics.Color.Black); gradientDrawable.SetAlpha(153); Control.SetPadding(20, 10, 20, 10); Control.Gravity = GravityFlags.Center; Control.SetBackground(gradientDrawable); } }
bool IViewHierarchyHandler.TryGetHighlightedView(double x, double y, bool clear, out IInspectView chosenView) { chosenView = null; if (highlightedView != null) { highlightedView.SetBackgroundDrawable(highlightedViewOriginalBackground); highlightedView = null; highlightedViewOriginalBackground = null; } var view = GetViewAt(GetTopActivity(), x, y); if (view == null) { return(false); } if (!clear) { highlightedView = view; highlightedViewOriginalBackground = this.highlightedView.Background; var gd = new GradientDrawable(); gd.SetColor(AG.Color.Red.ToArgb()); gd.SetAlpha(255 / 2); //gd.SetCornerRadius (5); //gd.SetStroke (1, AG.Color.Red); Drawable highlightedBackground; if (highlightedViewOriginalBackground == null) { highlightedBackground = gd; } else { highlightedBackground = new LayerDrawable(new [] { highlightedViewOriginalBackground, gd }); } highlightedView.SetBackgroundDrawable(highlightedBackground); } chosenView = new AndroidInspectView(view, withSubviews: false); return(true); }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (e.OldElement != null) { return; } var gradientDrawable = new GradientDrawable(); gradientDrawable.SetCornerRadius(60f); gradientDrawable.SetStroke(5, Android.Graphics.Color.LightGray); gradientDrawable.SetColor(Android.Graphics.Color.LightGray); gradientDrawable.SetAlpha(100); Control.SetBackground(gradientDrawable); Control.SetPadding(50, Control.PaddingTop, Control.PaddingRight, Control.PaddingBottom); }