コード例 #1
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);
            if (e.OldElement != null)
            {
                _pbEntry = e.OldElement as PaddingBorderEntry;
            }
            if (e.NewElement != null)
            {
                _pbEntry = e.NewElement as PaddingBorderEntry;
            }
            if (Element != null)
            {
                _pbEntry = Element as PaddingBorderEntry;
            }

            if (Control != null)
            {
                if (_pbEntry.IsCurvedCornersEnabled)
                {
                    // creating gradient drawable for the curved background
                    var _gradientBackground = new GradientDrawable();
                    _gradientBackground.SetShape(ShapeType.Rectangle);
                    //_gradientBackground.SetAlpha(_pbEntry.BackgroundOpacity);
                    _gradientBackground.SetColor(_pbEntry.Background.ToAndroid());
                    //_gradientBackground.Alpha = _pbEntry.BackgroundOpacity;
                    // set the background of the
                    if (_pbEntry.HasBorder)
                    {
                        // Thickness of the stroke line
                        _gradientBackground.SetStroke(_pbEntry.BorderWidth, _pbEntry.BorderColor.ToAndroid());
                    }
                    else
                    {
                        _gradientBackground.SetStroke(0, Color.Transparent.ToAndroid());
                    }

                    // Radius for the curves
                    _gradientBackground.SetCornerRadius(DpToPixels(Context, Convert.ToSingle(_pbEntry.CornerRadius)));

                    Control.SetBackground(_gradientBackground);
                }
                Control.Gravity = Android.Views.GravityFlags.CenterVertical;
                Control.SetPadding((int)_pbEntry.Padding.Left, (int)_pbEntry.Padding.Top, (int)_pbEntry.Padding.Right, (int)_pbEntry.Padding.Bottom);
            }
        }
コード例 #2
0
        private void UpdateBackground(AppEntry entryEx)
        {
            // creating gradient drawable for the curved background  
            var _gradientBackground = new GradientDrawable();

            _gradientBackground.SetShape(ShapeType.Rectangle);
            _gradientBackground.SetColor(entryEx.BackgroundColor.ToAndroid());

            // Thickness of the stroke line  
            _gradientBackground.SetStroke(entryEx.BorderWidth, entryEx.BorderColor.ToAndroid());

            // Radius for the curves  
            _gradientBackground.SetCornerRadius(DpToPixels(this.Context, Convert.ToSingle(entryEx.CornerRadius)));

            // set the background of the   
            Control.SetBackground(_gradientBackground);
        }
コード例 #3
0
        protected override void OnElementChanged(ElementChangedEventArgs <Editor> e)
        {
            base.OnElementChanged(e);
            if (e.NewElement != null)
            {
                if (Element is SupportEditor)
                {
                    supportEditor = Element as SupportEditor;

                    GradientDrawable gd = new GradientDrawable();
                    gd.SetCornerRadius((float)supportEditor.CornerRadius);
                    gd.SetStroke((int)supportEditor.CornerWidth, supportEditor.CornerColor.ToAndroid());
                    Control.SetBackground(gd);
                    InitlizeReturnKey();
                }
            }
        }
コード例 #4
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);
            var view    = (CustomEntry)Element;
            var outline = new GradientDrawable();

            outline.SetShape(ShapeType.Rectangle);
            outline.SetColor(view.BackgroundColor.ToAndroid());
            outline.SetStroke(view.BorderWidth, view.BorderColor.ToAndroid());

            if (view.IsCurvedCornersEnabled)
            {
                outline.SetCornerRadius(15f);
            }
            Control.SetPadding(20, Control.PaddingTop, 20, Control.PaddingTop);
            Control.SetBackground(outline);
        }
コード例 #5
0
        public static void UpdateBackground(Border border, Android.Views.View view)
        {
            var strokeThickness = border.StrokeThickness;
            var context         = view.Context;

            // create stroke drawable
            GradientDrawable strokeDrawable = null;

            // if thickness exists, set stroke drawable stroke and radius
            if (strokeThickness.HorizontalThickness + strokeThickness.VerticalThickness > 0)
            {
                strokeDrawable = new GradientDrawable();
                strokeDrawable.SetColor(border.BackgroundColor.ToAndroid());

                // choose thickest margin
                // the content is padded so it will look like the margin is with the given thickness
                strokeDrawable.SetStroke((int)context.ToPixels(strokeThickness.ThickestSide()), border.Stroke.ToAndroid());
                strokeDrawable.SetCornerRadius((float)border.CornerRadius);
            }

            // create background drawable
            var backgroundDrawable = new GradientDrawable();

            // set background drawable color based on Border's background color
            backgroundDrawable.SetColor(border.BackgroundColor.ToAndroid());
            backgroundDrawable.SetCornerRadius((float)border.CornerRadius);

            if (strokeDrawable != null)
            {
                // if stroke drawable exists, create a layer drawable containing both stroke and background drawables
                var ld = new LayerDrawable(new Drawable[] { strokeDrawable, backgroundDrawable });
                ld.SetLayerInset(1, (int)context.ToPixels(strokeThickness.Left), (int)context.ToPixels(strokeThickness.Top), (int)context.ToPixels(strokeThickness.Right), (int)context.ToPixels(strokeThickness.Bottom));
                view.SetBackgroundDrawable(ld);
            }
            else
            {
                view.SetBackgroundDrawable(backgroundDrawable);
            }

            // set Android.View's padding to take into account the stroke thickiness
            view.SetPadding(
                (int)context.ToPixels(strokeThickness.Left + border.Padding.Left),
                (int)context.ToPixels(strokeThickness.Top + border.Padding.Top),
                (int)context.ToPixels(strokeThickness.Right + border.Padding.Right),
                (int)context.ToPixels(strokeThickness.Bottom + border.Padding.Bottom));
        }
コード例 #6
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == null)
            {
                var gradientDrawable = new GradientDrawable();

                gradientDrawable.SetColor(Android.Graphics.Color.Transparent);
                gradientDrawable.SetStroke(0, Android.Graphics.Color.Transparent);
                gradientDrawable.SetCornerRadius(0);

                Control.SetBackground(gradientDrawable);

                Control.SetPadding(0, 0, 0, 0);
            }
        }
コード例 #7
0
        void UpdateBorders(CustomEntryLabel element)
        {
            GradientDrawable shape = new GradientDrawable();

            shape.SetShape(ShapeType.Rectangle);
            shape.SetCornerRadius(10);

            if (element.IsEntrySelected)
            {
                shape.SetStroke(6, Android.Graphics.Color.Blue);
            }
            else
            {
                shape.SetStroke(2, Android.Graphics.Color.ParseColor("#808080"));//shape.SetStroke(2, element.EntryBorderColor.ToAndroid());
            }
            this.Control.SetBackground(shape);
        }
コード例 #8
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            var view = (CustomEntry)Element;

            if (Control != null)
            {
                var gd = new GradientDrawable();
                gd.SetCornerRadius(view.CornerRadius);
                gd.SetColor(view.NewBackgroundColor.ToAndroid());
                gd.SetStroke(view.BorderWidth, view.BorderColor.ToAndroid());
                Control.SetBackgroundColor(Color.Transparent);
                Control.SetPadding(20, Control.PaddingTop, Control.PaddingRight, Control.PaddingBottom);
                Control.SetBackground(gd);
            }
        }
コード例 #9
0
        private void InitBackground(int color, float cornerRadius)
        {
            GradientDrawable drawable = new GradientDrawable();

            drawable.SetShape(ShapeType.Rectangle);
            drawable.SetColor(color);
            drawable.SetCornerRadius(cornerRadius);
            if (Build.VERSION.SdkInt >= Build.VERSION_CODES.JellyBean)
            {
                Background = drawable;
            }
            else
            {
                //noinspection deprecation
                SetBackgroundDrawable(drawable);
            }
        }
コード例 #10
0
        void UpdateToolbarBackground(Android.Support.V7.Widget.Toolbar toolbar, Page lastPage, Activity activity, Android.Graphics.Drawables.Drawable defaultBackground)
        {
            if (string.IsNullOrEmpty(CustomNavigationPage.GetBarBackground(lastPage)) && CustomNavigationPage.GetGradientColors(lastPage) == null)
            {
                toolbar.SetBackground(defaultBackground);
            }
            else
            {
                if (!string.IsNullOrEmpty(CustomNavigationPage.GetBarBackground(lastPage)))
                {
                    toolbar.SetBackgroundResource(this.Context.Resources.GetIdentifier(CustomNavigationPage.GetBarBackground(lastPage), "drawable", Android.App.Application.Context.PackageName));
                }

                if (CustomNavigationPage.GetGradientColors(lastPage) != null)
                {
                    var colors    = CustomNavigationPage.GetGradientColors(lastPage);
                    var direction = GradientDrawable.Orientation.TopBottom;
                    switch (CustomNavigationPage.GetGradientDirection(lastPage))
                    {
                    case CustomNavigationPage.GradientDirection.BottomToTop:
                        direction = GradientDrawable.Orientation.BottomTop;
                        break;

                    case CustomNavigationPage.GradientDirection.RightToLeft:
                        direction = GradientDrawable.Orientation.RightLeft;
                        break;

                    case CustomNavigationPage.GradientDirection.LeftToRight:
                        direction = GradientDrawable.Orientation.LeftRight;
                        break;
                    }

                    GradientDrawable gradient = new GradientDrawable(direction, new int[] { colors.Item1.ToAndroid().ToArgb(), colors.Item2.ToAndroid().ToArgb() });
                    gradient.SetCornerRadius(0f);
                    if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.JellyBean)
                    {
                        toolbar.SetBackground(gradient);
                    }
                    else
                    {
                        toolbar.SetBackgroundDrawable(gradient);
                    }
                }
            }
            toolbar.Background.SetAlpha((int)(CustomNavigationPage.GetBarBackgroundOpacity(lastPage) * 255));
        }
コード例 #11
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == null)
            {
                //Control.SetBackgroundResource(Resource.Layout.rounded_shape);
                var gradientDrawable = new GradientDrawable();
                gradientDrawable.SetCornerRadius(60f);
                gradientDrawable.SetStroke(2, Android.Graphics.Color.Black);
                gradientDrawable.SetColor(Android.Graphics.Color.ParseColor("#FFFFFF"));     //color en Hex
                Control.SetHintTextColor(global::Android.Graphics.Color.Rgb(182, 182, 182)); // color en rgb
                Control.SetBackground(gradientDrawable);

                Control.SetPadding(50, 35, Control.PaddingRight, 5);
            }
        }
コード例 #12
0
ファイル: CustomEntry.cs プロジェクト: coreblazer/License
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == null)
            {
                //Control.SetBackgroundResource(Resource.Layout.rounded_shape);
                var gradientDrawable = new GradientDrawable();
                gradientDrawable.SetCornerRadius(60f);
                gradientDrawable.SetStroke(5, Android.Graphics.Color.DarkGray);
                gradientDrawable.SetColor(Android.Graphics.Color.Transparent);
                Control.SetBackground(gradientDrawable);
                e.NewElement.PlaceholderColor = Color.Gray;
                Control.SetPadding(50, Control.PaddingTop, Control.PaddingRight,
                                   Control.PaddingBottom);
            }
        }
コード例 #13
0
ファイル: CustomButton_Droid.cs プロジェクト: VPAF/Grid
        protected override void OnElementChanged(ElementChangedEventArgs <Button> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                return;
            }
            {
                var gradientDrawable = new GradientDrawable();
                gradientDrawable.SetShape(ShapeType.Rectangle);
                gradientDrawable.SetColor(Element.BackgroundColor.ToAndroid(Color.FromRgb(255, 215, 0)));
                gradientDrawable.SetStroke(4, Element.BorderColor.ToAndroid());
                gradientDrawable.SetCornerRadius(30.0f);
                Control.SetBackground(gradientDrawable);
            }
        }
コード例 #14
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == null)
            {
                var gradiantDrawable = new GradientDrawable();

                gradiantDrawable.SetCornerRadius(10f);
                gradiantDrawable.SetStroke(1, Android.Graphics.Color.Black);
                gradiantDrawable.SetColor(Android.Graphics.Color.White);

                Control.SetBackground(gradiantDrawable);

                Control.SetPadding(50, Control.PaddingTop, Control.PaddingRight, Control.PaddingBottom);
            }
        }
コード例 #15
0
        public static void SetTheme(this TextView textView, string backgroundColor = null, string textColor = null,
                                    string textSize = null, int cornerRadius = 0, string fontStyle = null, string drawableEnd = null)

        {
            GradientDrawable gradientDrawable = new GradientDrawable();

            if (!string.IsNullOrWhiteSpace(backgroundColor))
            {
                gradientDrawable.SetColor(_theme.Colors[backgroundColor]);
            }
            gradientDrawable.SetCornerRadius(cornerRadius);

            textView.Background = gradientDrawable;

            if (!string.IsNullOrWhiteSpace(textColor))
            {
                textView.SetTextColor(_theme.Colors[textColor]);
            }
            if (!string.IsNullOrWhiteSpace(textSize))
            {
                textView.SetTextSize(ComplexUnitType.Sp, _theme.FontSizes[textSize]);
            }

            if (!string.IsNullOrWhiteSpace(fontStyle))
            {
                switch (_theme.FontStyles[fontStyle])
                {
                case EFontStyle.Bold:
                    textView.SetTypeface(Typeface.Default, TypefaceStyle.Bold);
                    break;

                case EFontStyle.Italic:
                    textView.SetTypeface(Typeface.Default, TypefaceStyle.Italic);
                    break;

                case EFontStyle.Underline:
                    textView.PaintFlags = PaintFlags.UnderlineText;
                    break;

                case EFontStyle.Normal:
                default:
                    textView.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                    break;
                }
            }
        }
コード例 #16
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Button> e)
        {
            base.OnElementChanged(e);
            var newEl = e.NewElement as GradientButton;

            if (newEl != null)
            {
                var gradient = new GradientDrawable(GradientDrawable.Orientation.TopBottom, new int[]
                {
                    newEl.Start.ToAndroid(),
                    newEl.End.ToAndroid()
                });
                var height = Control.MinHeight;
                gradient.SetCornerRadius((float)height / 2);
                Control.Background = gradient;
            }
        }
コード例 #17
0
        protected override void OnElementChanged(ElementChangedEventArgs <Frame> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement is ExtendedFrame origFrame)
            {
                var gi = new GradientDrawable();

                _gi = gi;

                gi.SetStroke(origFrame.BorderThickness, origFrame.BorderColor.ToAndroid());
                gi.SetColor(origFrame.BackgroundColor.ToAndroid());
                gi.SetCornerRadius(origFrame.CornerRadius);
//                SetBackgroundDrawable(gi);
                this.SetBackground(gi);
            }
        }
コード例 #18
0
        private void UpdateBackground()
        {
            var   btn             = this.Element;
            Color backgroundColor = btn?.BackgroundColor ?? Color.Transparent;

            if (backgroundColor != null && backgroundColor != Color.Transparent)
            {
                GradientDrawable drawable = new GradientDrawable();
                drawable.SetColor(backgroundColor.ToAndroid());
                drawable.SetCornerRadius(DpToPx(6));
                drawable.SetStroke(1, Color.FromHex("#c6c6c6").ToAndroid());

                Control.Background = drawable;

                btn.BackgroundColor = Color.Transparent;
            }
        }
コード例 #19
0
        private void SetGradientBackground()
        {
            var control = (GradientNavigationPage)this.Element;

            int[] colors = new int[] { control.StartColor.ToAndroid().ToArgb(), control.EndColor.ToAndroid().ToArgb() };

            switch (control.Direction)
            {
            default:
            case GradientDirection.ToRight:
                gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.LeftRight, colors);
                break;

            case GradientDirection.ToLeft:
                gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.RightLeft, colors);
                break;

            case GradientDirection.ToTop:
                gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.BottomTop, colors);
                break;

            case GradientDirection.ToBottom:
                gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.TopBottom, colors);
                break;

            case GradientDirection.ToTopLeft:
                gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.BrTl, colors);
                break;

            case GradientDirection.ToTopRight:
                gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.BlTr, colors);
                break;

            case GradientDirection.ToBottomLeft:
                gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.TrBl, colors);
                break;

            case GradientDirection.ToBottomRight:
                gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.TlBr, colors);
                break;
            }
            gradientDrawable.SetCornerRadius(0f);

            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            toolbar.SetBackground(gradientDrawable);
        }
コード例 #20
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == null)
            {
                var gradientDrawable = new GradientDrawable();
                var nativeEditText   = (EditText)Control;

                gradientDrawable.SetCornerRadius(60f);
                gradientDrawable.SetStroke(5, Android.Graphics.Color.White);
                gradientDrawable.SetColor(Android.Graphics.Color.Transparent);

                Control.SetBackground(gradientDrawable);
                Control.SetPadding(50, Control.PaddingTop, Control.PaddingRight, Control.PaddingBottom);
            }
        }
コード例 #21
0
        void UpdateBackground()
        {
            if (_disposed || Element == null)
            {
                return;
            }

            var bgBrush = Element.Background;

            if (Brush.IsNullOrEmpty(bgBrush))
            {
                var bgColor = Element.BackgroundColor;

                if (bgColor.IsDefault && _defaultBackgroundColor == null)
                {
                    return;
                }

                if (_defaultBackgroundDrawable != null)
                {
                    Background = _defaultBackgroundDrawable;
                }

                if (_defaultBackgroundColor == null)
                {
                    _defaultBackgroundColor = CardBackgroundColor.DefaultColor;
                }

                SetCardBackgroundColor(bgColor.IsDefault ? _defaultBackgroundColor.Value : bgColor.ToAndroid());
            }
            else
            {
                if (_defaultBackgroundDrawable == null)
                {
                    _defaultBackgroundDrawable = Background;
                }

                _backgroundGradientDrawable = new GradientDrawable();
                _backgroundGradientDrawable.SetShape(ShapeType.Rectangle);

                _backgroundGradientDrawable.SetCornerRadius(Radius);
                _backgroundGradientDrawable.UpdateBackground(bgBrush, Height, Width);

                Background = _backgroundGradientDrawable;
            }
        }
コード例 #22
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == null)
            {
                var gradientDrawable = new GradientDrawable();
                gradientDrawable.SetCornerRadius(30f);
                gradientDrawable.SetStroke(6, Android.Graphics.Color.Rgb(67, 146, 216));
                gradientDrawable.SetColor(Android.Graphics.Color.Argb(125, 3, 164, 153));
                //gradientDrawable.SetSize(240, 49);
                Control.SetBackground(gradientDrawable);

                Control.SetPadding(25, Control.PaddingTop, Control.PaddingRight,
                                   Control.PaddingBottom);
            }
        }
コード例 #23
0
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Entry> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == null)
            {
                var gradient = new GradientDrawable();
                gradient.SetCornerRadius(50f);
                gradient.SetStroke(1, Android.Graphics.Color.White);
                gradient.SetColor(Color.FromHex("6e6696").ToAndroid());

                this.Control.Gravity = GravityFlags.CenterHorizontal;
                this.Control.SetBackground(gradient);
                this.Control.SetCursorVisible(false);
                this.Control.SetPadding(0, 10, 0, 0);
            }
        }
コード例 #24
0
        protected override void OnElementChanged(ElementChangedEventArgs <Frame> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                var contr = e.NewElement as FrameShadow;

                Elevation = contr.Elevation;

                GradientDrawable gd = new GradientDrawable();
                gd.SetColor(contr.BackgroundColor.ToAndroid());
                gd.SetCornerRadius(contr.CornerRadius * 2);

                Background = gd;
            }
        }
コード例 #25
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                var element          = this.Element as RoundedEntry;
                var gradientDrawable = new GradientDrawable();
                gradientDrawable.SetCornerRadius((float)element.BorderRadius);
                gradientDrawable.SetStroke((int)element.BorderWidth, ((Color)element.BorderColor).ToAndroid());
                gradientDrawable.SetColor(((Color)element.BgColor).ToAndroid());

                Control.SetBackground(gradientDrawable);

                Control.SetPadding(50, Control.PaddingTop, Control.PaddingRight, Control.PaddingBottom);
            }
        }
コード例 #26
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);


            if (e.OldElement == null)
            {
                //Control.SetBackgroundResource(Resource.Layout.rounded_shape);
                var gradientDrawable = new GradientDrawable();
                gradientDrawable.SetCornerRadius(60f);
                gradientDrawable.SetStroke(5, Android.Graphics.Color.Rgb(93, 175, 226));
                gradientDrawable.SetColor(Android.Graphics.Color.LightGray);
                Control.SetBackground(gradientDrawable);

                Control.SetPadding(50, Control.PaddingTop, Control.PaddingRight, Control.PaddingBottom);
            }
        }
コード例 #27
0
        private void SetUnfocusedBoxStyles(XEntry element)
        {
            if (Control != null)
            {
                var gradientDrawable = new GradientDrawable();

                // Border Radius.
                var borderRadiusPx = ConvertToPx(Convert.ToInt32(element.BoxBorderRadius));
                gradientDrawable.SetCornerRadius(borderRadiusPx);

                // Border Color.
                var edgeSizePx = ConvertToPx(element.BoxEdgeSize);
                gradientDrawable.SetStroke(edgeSizePx, element.BorderColor.ToAndroid());

                Control.SetBackground(gradientDrawable);
            }
        }
コード例 #28
0
        private void OnReleased(object sender, EventArgs e)
        {
            if (Control == null)
            {
                return;
            }
            var roundedButton    = (RoundedButton)Element;
            var gradientDrawable = new GradientDrawable();

            gradientDrawable.SetShape(ShapeType.Rectangle);
            gradientDrawable.SetColor(roundedButton.BackgroundColor.ToAndroid());
            gradientDrawable.SetStroke(Convert.ToInt32(roundedButton.BorderWidth),
                                       roundedButton.BorderColor.ToAndroid());
            gradientDrawable.SetCornerRadius(roundedButton.BorderRadius);
            Control.SetBackground(gradientDrawable);
            Control.SetTextColor(roundedButton.TextColor.ToAndroid());
        }
コード例 #29
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                var customEntry = (CustomEntry)Element;

                if (customEntry.BorderEnabled == true)
                {
                    GradientDrawable gradient = new GradientDrawable();
                    gradient.SetCornerRadius((float)customEntry.CornerRadius);
                    gradient.SetStroke(customEntry.StrokeThickness, customEntry.StrokeColor.ToAndroid());
                    Control.Background = gradient;
                }
            }
        }
コード例 #30
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || e.NewElement == null)
            {
                return;
            }

            element = (RoundedEntry)this.Element;
            var editText = this.Control;

            var gradientDrawable = new GradientDrawable();

            gradientDrawable.SetCornerRadius(60f);
            gradientDrawable.SetStroke(2, Android.Graphics.Color.Gray);
            gradientDrawable.SetColor(Android.Graphics.Color.White);
            editText.SetBackground(gradientDrawable);

            editText.SetPadding(15, Control.PaddingTop, Control.PaddingRight, Control.PaddingBottom);
            if (!string.IsNullOrEmpty(element.Image))
            {
                switch (element.ImageAlignment)
                {
                case ImageAlignment.Left:
                    editText.SetCompoundDrawablesWithIntrinsicBounds(GetDrawable(element.Image), null, null, null);
                    break;

                case ImageAlignment.Right:
                    editText.SetCompoundDrawablesWithIntrinsicBounds(null, null, GetDrawable(element.Image), null);
                    break;
                }
            }
            //if(e.OldElement == null)
            //{
            //   var gradientDrawable = new GradientDrawable();
            //    gradientDrawable.SetCornerRadius(60f);
            //    gradientDrawable.SetStroke(2, Android.Graphics.Color.Gray);
            //    gradientDrawable.SetColor(Android.Graphics.Color.White);
            //    Control.SetBackground(gradientDrawable);

            //    Control.SetPadding(50, Control.PaddingTop, Control.PaddingRight, Control.PaddingBottom);

            //}
        }