Example #1
0
        /*nuovo*/
        private void UpdateBackground(CualevaPicker entryEx)
        {
            var gradientDrawable = new GradientDrawable();

            gradientDrawable.SetCornerRadius(entryEx.BorderRadius);
            gradientDrawable.SetStroke((int)entryEx.BorderWidth, entryEx.BorderColor.ToAndroid());
            gradientDrawable.SetColor(entryEx.CualevaRoundedEntryBackgroundColor.ToAndroid());

            if (!string.IsNullOrWhiteSpace(entryEx.Image))
            {
                List <Drawable> layers = new List <Drawable>();
                layers.Add(gradientDrawable);
                var ly = GetDrawable(entryEx.Image, entryEx.BorderRadius);
                if (ly != null)
                {
                    layers.Add(ly);
                }
                LayerDrawable layerDrawable = new LayerDrawable(layers.ToArray());
                layerDrawable.SetLayerInset(0, 0, 0, 0, 0);
                Control.SetBackground(layerDrawable);
            }
            else
            {
                Control.SetBackground(gradientDrawable);
            }
        }
Example #2
0
        protected override void OnElementChanged(ElementChangedEventArgs <Picker> e)
        {
            base.OnElementChanged(e);

            element = (CualevaPicker)this.Element;

            if (Control != null && this.Element != null && !string.IsNullOrEmpty(element.Image))
            {
                Control.Background = AddPickerStyles(element.Image);
            }
            UpdateBackground(element);
            var spaceFont = Typeface.CreateFromAsset(Xamarin.Forms.Forms.Context.ApplicationContext.Assets, "fonts/Montserrat-Regular.ttf");

            Control.Typeface = spaceFont;
        }
Example #3
0
        public LayerDrawable AddPickerStyles(string imagePath)
        {
            element = (CualevaPicker)this.Element;
            ShapeDrawable border = new ShapeDrawable();

            border.Paint.Color = Android.Graphics.Color.Gray;
            border.SetPadding(10, 10, 10, 10);
            border.Paint.SetStyle(Paint.Style.Stroke);
            Drawable[]      layers = { border, GetDrawable(imagePath, element.BorderRadius) };
            List <Drawable> L1     = new List <Drawable>();

            foreach (var item in layers)
            {
                if (item != null)
                {
                    L1.Add(item);
                }
            }
            LayerDrawable layerDrawable = new LayerDrawable(L1.ToArray());

            layerDrawable.SetLayerInset(0, 0, 0, 0, 0);
            return(layerDrawable);
        }