private void SetBackgroundColorAndStroke() { var bkColor = RoundedCornersEffect.GetBackgroundColor(Element).ToAndroid(); gradientDrawable.SetColor(bkColor); gradientDrawable.SetStroke(1, bkColor); //required. Could be customized if PCL class RoundedCornersEffect is expanded }
public RoundedCornerEffectView() { InitializeComponent(); // Add the rounded corner effect to the view CustomGrid.Effects.Add(Effect.Resolve(RoundedCornersEffect.EffectName)); // Set the corner radius RoundedCornersEffect.SetCornerRadius(CustomGrid, 20); }
private void SetCornerRadius() { var cornerRadius = RoundedCornersEffect.GetCornerRadius(Element) * GetDensity(); Container.OutlineProvider = new RoundedOutlineProvider(cornerRadius); }
protected override void OnAttached() { try { gradientDrawable = new GradientDrawable(); gradientDrawable.SetShape(ShapeType.Rectangle); SetBackgroundColorAndStroke(); gradientDrawable.SetCornerRadius(DpToPixels(Android.App.Application.Context, RoundedCornersEffect.GetCornerRadius(Element))); Control.SetBackground(gradientDrawable); } catch (Exception ex) { Console.WriteLine("Cannot set property on attached control. Error: {0}", ex.Message); } }
private void SetCornerRadius() { var cornerRadius = RoundedCornersEffect.GetCornerRadius(Element); Container.Layer.CornerRadius = new nfloat(cornerRadius); }