//private void CheckEnabled() //{ // if (Element.IsEnabled) // { // if (!Element.AllowCutCopyPaste) // { // Control.RequestFocus(); // UIHelper.OpenSoftKeyboard(Control); // } // } // else // { // if (!Element.AllowCutCopyPaste) // { // UIHelper.CloseSoftKeyboard(Control); // } // } //} private void CreateShapeDrawable() { GradientDrawable shape = new GradientDrawable(); shape.SetShape(ShapeType.Rectangle); shape.SetCornerRadius(BaseUIHelper.ConvertDPToPixels(Element.CornerRadius)); if (Element.BackgroundColor != Xamarin.Forms.Color.Default) { shape.SetColor(Element.BackgroundColor.ToAndroid()); } if (Element.ImageRight != null && Element.ImageRight.File != null) { Drawable drawable = Context.Resources.GetDrawable(UIHelper.GetDrawableResource(Element.ImageRight)); drawable.SetBounds(0, 0, BaseUIHelper.ConvertDPToPixels(Element.ImageRightWidth), BaseUIHelper.ConvertDPToPixels(Element.ImageRightHeight)); Control.SetCompoundDrawablesRelative(null, null, drawable, null); } //if (Element.CornerRadius > 0) // this.SetPadding(5, 2, 5, 2); Control.Background = shape; }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.DatePicker> e) { base.OnElementChanged(e); this.Control.SetTextColor(Color.FromHex("0D47A1").ToAndroid()); //this.Control.SetBackgroundColor(Android.Graphics.Color.Black); //this.Control.Gravity = GravityFlags.Start; this.Control.SetPadding(5, 0, 5, 0); //this.Control.TextAlignment = TextAlignmentTextStart; GradientDrawable gd = new GradientDrawable(); //gd.SetCornerRadius(0); //increase or decrease to changes the corner look //gd.SetColor(Android.Graphics.Color.Transparent); gd.SetStroke(0, Color.FromHex("0D47A1").ToAndroid()); this.Control.SetBackgroundDrawable(gd); //GradientDrawable gd = new GradientDrawable(); //gd.SetCornerRadius(25); //increase or decrease to changes the corner look //gd.SetColor(Android.Graphics.Color.Transparent); //gd.SetStroke(3, Color.FromHex("0D47A1").ToAndroid()); //this.Control.SetBackgroundDrawable(gd); }
void UpdateToolbarShadow(Android.Support.V7.Widget.Toolbar toolbar, bool hasShadow, Activity activity, Android.Graphics.Drawables.Drawable windowContent) { var androidContent = activity?.Window?.DecorView?.FindViewById <FrameLayout>(Window.IdAndroidContent); if (androidContent != null) { if (hasShadow && activity != null) { GradientDrawable shadowGradient = new GradientDrawable(GradientDrawable.Orientation.RightLeft, new int[] { Android.Graphics.Color.Transparent.ToArgb(), Android.Graphics.Color.Gray.ToArgb() }); shadowGradient.SetCornerRadius(0f); androidContent.Foreground = shadowGradient; toolbar.Elevation = 4; } else { androidContent.Foreground = windowContent; toolbar.Elevation = 0; } } }
public static void InitializeFrom(this Android.Views.View nativeControl, RoundedBoxView formsControl) { if (nativeControl == null || formsControl == null) { return; } var background = new GradientDrawable(); background.SetColor(formsControl.RoundedBackgroudColor.ToAndroid()); if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean) { nativeControl.Background = background; } else { nativeControl.SetBackgroundDrawable(background); } nativeControl.UpdateCornerRadius(formsControl.CornerRadius); nativeControl.UpdateBorder(formsControl.RoundedBackgroudColor, formsControl.BorderThickness); nativeControl.UpdateSize(Convert.ToInt32(formsControl.WidthRequest), Convert.ToInt32(formsControl.HeightRequest)); }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (Control == null || e.NewElement == null) { return; } if (e.NewElement != null) { element = (CustomEntry)Element; if (element.IsCurvedCornersEnabled) { var _gradientBackground = new GradientDrawable(); _gradientBackground.SetShape(ShapeType.Rectangle); _gradientBackground.SetColor(element.BackgroundColor.ToAndroid()); _gradientBackground.SetStroke(element.BorderWidth, element.BorderColor.ToAndroid()); _gradientBackground.SetCornerRadius( DpToPixels(this.Context, System.Convert.ToSingle(element.CornerRadius))); Control.SetBackground(_gradientBackground); } Control.CompoundDrawablePadding = 25; Control.SetPadding( (int)DpToPixels(this.Context, System.Convert.ToSingle(5)), Control.PaddingTop, (int)DpToPixels(this.Context, System.Convert.ToSingle(5)), Control.PaddingBottom); } }
protected void ChangeBackgroundPattern() { if (!(Element is CalendarButton element) || element.BackgroundPattern == null || Control.Width == 0) { return; } var d = new List <Drawable>(); for (var i = 0; i < element.BackgroundPattern.Pattern.Count; i++) { d.Add(new ColorDrawable(element.BackgroundPattern.Pattern[i].Color.ToAndroid())); } var drawable = new GradientDrawable(); drawable.SetShape(ShapeType.Rectangle); drawable.SetStroke((int)Element.BorderWidth, Element.BorderColor.ToAndroid()); drawable.SetColor(Android.Graphics.Color.Transparent); d.Add(drawable); var layer = new LayerDrawable(d.ToArray()); for (var i = 0; i < element.BackgroundPattern.Pattern.Count; i++) { var l = (int)(Control.Width * element.BackgroundPattern.GetLeft(i)); var t = (int)(Control.Height * element.BackgroundPattern.GetTop(i)); var r = (int)(Control.Width * (1 - element.BackgroundPattern.Pattern[i].WidthPercent)) - l; var b = (int)(Control.Height * (1 - element.BackgroundPattern.Pattern[i].HightPercent)) - t; layer.SetLayerInset(i, l, t, r, b); } layer.SetLayerInset(d.Count - 1, 0, 0, 0, 0); Control.SetBackground(layer); }
protected override void OnElementChanged(ElementChangedEventArgs <Label> e) { base.OnElementChanged(e); var view = (CurvedCornersLabel)Element; if (view == null) { return; } // creating gradient drawable for the curved background _gradientBackground = new GradientDrawable(); _gradientBackground.SetShape(ShapeType.Rectangle); _gradientBackground.SetColor(view.CurvedBackgroundColor.ToAndroid()); // Thickness of the stroke line _gradientBackground.SetStroke(4, view.CurvedBackgroundColor.ToAndroid()); // Radius for the curves _gradientBackground.SetCornerRadius(DpToPixels(this.Context, Convert.ToSingle(view.CurvedCornerRadius))); // set the background of the label Control.SetBackground(_gradientBackground); }
protected override void OnDetachedOverride() { if (!IsDisposed) { NativeButton.Background = OrgBackground; NativeButton.StateListAnimator = OrgStateListAnimator; System.Diagnostics.Debug.WriteLine($"{this.GetType().FullName} Detached Disposing"); } Colors.Dispose(); Shape.Dispose(); Inset.Dispose(); Ripple.Dispose(); FormsButton = null; NativeButton = null; OrgBackground = null; OrgStateListAnimator = null; Colors = null; Shape = null; Ripple = null; Inset = null; System.Diagnostics.Debug.WriteLine($"{this.GetType().FullName} Detached completely"); }
public TorqueHistogram(Context context) : base(context) { intervals = new List <TorqueInterval>(); outerContainer = new RelativeLayout(context); AddView(outerContainer); container = new LinearLayout(context); container.Orientation = Orientation.Horizontal; var drawable = new GradientDrawable(); drawable.SetColor(BackgroundColor); drawable.SetCornerRadius(5); container.Background = drawable; container.LayoutParameters = LayoutUtils.LinearMatchParent(); indicator = new TorqueIndicator(context); Counter = new TorqueCounter(context); Button = new TorqueButton(context); }
protected override void OnElementChanged(ElementChangedEventArgs <DatePickerXamDisableDates.DatePickerRender> e) { base.OnElementChanged(e); this.SetNativeControl(new Android.Widget.EditText(Forms.Context)); if (Control == null || e.NewElement == null) { return; } this.Control.Click += OnPickerClick; this.Control.Text = Element.Date.ToString(Element.Format); this.Control.KeyListener = null; this.Control.FocusChange += OnPickerFocusChange; this.Control.Enabled = Element.IsEnabled; CreateDatePickerDialog(this.Element.Date.Year, this.Element.Date.Month - 1, this.Element.Date.Day); GradientDrawable gd = new GradientDrawable(); gd.SetStroke(0, Android.Graphics.Color.Transparent); Control.SetBackgroundDrawable(gd); // SetDatemax(Element.Maximumdate); //UpdateMaximumDate(); // UpdateMinimumDate(); // SetDatemin(Element.Minimumdate); }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); CustomEntry elementcustom; if (Control != null) { GradientDrawable gd = new GradientDrawable(); // increase or decrease to changes the corner gd.SetCornerRadius(18); elementcustom = (CustomEntry)this.Element; Android.Graphics.Color col = elementcustom.BorderColor.ToAndroid(); gd.SetStroke(1, Android.Content.Res.ColorStateList.ValueOf(col)); this.Control.SetBackgroundDrawable(gd); } }
private void Paint(CustomButton view, string startColor, string EndColor) { int[] colors = { Android.Graphics.Color.ParseColor(startColor), Android.Graphics.Color.ParseColor(EndColor) }; int[] colors2 = { Android.Graphics.Color.ParseColor(EndColor), Android.Graphics.Color.ParseColor(startColor) }; _gradientBackground = new GradientDrawable(GradientDrawable.Orientation.LeftRight, colors); colorStateList = new ColorStateList(new int[][] { new int[] {}, new int[] {} }, colors2); //_gradientBackground.SetShape(ShapeType.Rectangle); //_gradientBackground.SetColors(colors); //_gradientBackground.SetColor(view.CustomBackgroundColor.ToAndroid()); // Thickness of the stroke line _gradientBackground.SetStroke((int)view.CustomBorderWidth, view.CustomBorderColor.ToAndroid()); // Radius for the curves _gradientBackground.SetCornerRadius( DpToPixels(this.Context, Convert.ToSingle(view.CustomBorderRadius))); // set the background of the label Control.SetBackground(_gradientBackground); Control.SetTextColor(colorStateList); Control.SetPadding(2, 2, 2, 2); }
protected override void OnElementChanged(ElementChangedEventArgs<Button> e) { base.OnElementChanged(e); if (e.NewElement != null) { // Subscribe for events } else if (e.OldElement != null) { // Unsubscribe from events } if (Control != null) { GradientDrawable gradientDrawable = new GradientDrawable(); gradientDrawable.SetShape(ShapeType.Rectangle); gradientDrawable.SetColor(Element.BackgroundColor.ToAndroid()); gradientDrawable.SetStroke(4, Element.BorderColor.ToAndroid()); gradientDrawable.SetCornerRadius(38.0f); Control.SetBackground(gradientDrawable); } }
private void setWhiteNavigationBar(Dialog dialog) { Window window = dialog.Window; if (window != null) { DisplayMetrics metrics = new DisplayMetrics(); window.WindowManager.DefaultDisplay.GetMetrics(metrics); GradientDrawable dimDrawable = new GradientDrawable(); // ...customize your dim effect here GradientDrawable navigationBarDrawable = new GradientDrawable(); //navigationBarDrawable.Shape = GradientDrawable.Rectangle; navigationBarDrawable.SetColor(Color.White); Drawable[] layers = { dimDrawable, navigationBarDrawable }; LayerDrawable windowBackground = new LayerDrawable(layers); windowBackground.SetLayerInsetTop(1, metrics.HeightPixels); window.SetBackgroundDrawable(windowBackground); } }
public override View GetView(int position, View convertView, ViewGroup parent) { var view = convertView; if (view == null) { view = LayoutInflater.From(mContext).Inflate(Resource.Layout.boxCustomColor, null, false); } TextView tvColor = view.FindViewById <TextView>(Resource.Id.tvColor); tvColor.Text = mColors[position].Number.ToString(); string getColor = mColors[position].Color; //tvColor.SetBackgroundColor(Android.Graphics.Color.ParseColor(getColor)); GradientDrawable bgBoxColor = new GradientDrawable(); bgBoxColor.SetColor(Android.Graphics.Color.ParseColor(getColor)); bgBoxColor.SetShape(ShapeType.Oval); tvColor.Background = bgBoxColor; return(view); }
protected override void OnElementChanged(ElementChangedEventArgs <Button> e) { base.OnElementChanged(e); if (Control != null) { var button = (RoundedButton)e.NewElement; if (button != null) { button.SizeChanged += (s, args) => { // for corner round var radius = (float)Math.Min(button.Width, button.Height); // Create a drawable for the button's normal state _normal = new GradientDrawable(); _normal.SetCornerRadius(radius); }; Control.SetAllCaps(false); if (!string.IsNullOrEmpty((FileImageSource)button.ImageSource)) { Control.SetPadding(Control.PaddingLeft * 4, Control.PaddingTop, Control.PaddingRight * 4, Control.PaddingBottom); } // For Custom Font if (!string.IsNullOrEmpty(button.FontFamily)) { Typeface typeface = Typeface.CreateFromAsset(this.Context.Assets, button.FontFamily); Control.SetTypeface(typeface, TypefaceStyle.Bold); } } } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Button> e) { base.OnElementChanged(e); if (Control != null) { var button = e.NewElement; // Create a drawable for the button's normal state _normal = new Android.Graphics.Drawables.GradientDrawable(); if (button.BackgroundColor.R == -1.0 && button.BackgroundColor.G == -1.0 && button.BackgroundColor.B == -1.0) { _normal.SetColor(Android.Graphics.Color.ParseColor("#ff2c2e2f")); } else { _normal.SetColor(button.BackgroundColor.ToAndroid()); } _normal.SetStroke((int)button.BorderWidth, button.BorderColor.ToAndroid()); _normal.SetCornerRadius(button.BorderRadius); // Create a drawable for the button's pressed state _pressed = new Android.Graphics.Drawables.GradientDrawable(); _pressed.SetColor(Android.Graphics.Color.ParseColor("#f0472a")); _pressed.SetStroke((int)button.BorderWidth, button.BorderColor.ToAndroid()); _pressed.SetCornerRadius(button.BorderRadius); // Add the drawables to a state list and assign the state list to the button var sld = new StateListDrawable(); sld.AddState(new int[] { Android.Resource.Attribute.StatePressed }, _pressed); sld.AddState(new int[] { }, _normal); Control.SetBackgroundDrawable(sld); } }
void CreateShapeDrawable() { GradientDrawable shape = new GradientDrawable(); shape.SetShape(ShapeType.Rectangle); float[] cornerRadii = new float[] { 10, 10, 10, 10, 10, 10, 10, 10 }; if (Base.CornerRadius != "-1") { var cornerRad = Base.CornerRadius.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); cornerRadii = new float[] { BaseUIHelper.ConvertDPToPixels(float.Parse(cornerRad[0])), BaseUIHelper.ConvertDPToPixels(float.Parse(cornerRad[1])), BaseUIHelper.ConvertDPToPixels(float.Parse(cornerRad[2])), BaseUIHelper.ConvertDPToPixels(float.Parse(cornerRad[3])), BaseUIHelper.ConvertDPToPixels(float.Parse(cornerRad[4])), BaseUIHelper.ConvertDPToPixels(float.Parse(cornerRad[5])), BaseUIHelper.ConvertDPToPixels(float.Parse(cornerRad[6])), BaseUIHelper.ConvertDPToPixels(float.Parse(cornerRad[7])) }; } shape.SetCornerRadii(cornerRadii); var element = Element as RoundedFrame; if (element.BackgroundColor != Xamarin.Forms.Color.Default) { shape.SetColor(element.BackgroundColor.ToAndroid()); } if (Base.HasBorder) { shape.SetStroke(1, Base.BorderColor.ToAndroid()); } Control.Background = shape; }
protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); var element = Element as CalendarButton; if (e.PropertyName == nameof(element.TextWithoutMeasure) || e.PropertyName == "Renderer") { Control.Text = element.TextWithoutMeasure; } if (e.PropertyName == nameof(Element.TextColor) || e.PropertyName == "Renderer") { Control.SetTextColor(Element.TextColor.ToAndroid()); } if (e.PropertyName == nameof(Element.BorderWidth) || e.PropertyName == nameof(Element.BorderColor) || e.PropertyName == nameof(Element.BackgroundColor) || e.PropertyName == "Renderer") { if (element.BackgroundPattern == null) { var drawable = new GradientDrawable(); drawable.SetShape(ShapeType.Rectangle); drawable.SetStroke((int)Element.BorderWidth, Element.BorderColor.ToAndroid()); drawable.SetColor(Element.BackgroundColor.ToAndroid()); Control.SetBackground(drawable); } else { ChangeBackgroundPattern(); } } if (e.PropertyName == nameof(element.BackgroundPattern)) { ChangeBackgroundPattern(); } }
protected async void ChangeBackgroundImage() { var element = Element as CalendarButton; if (element == null || element.BackgroundImage == null) { return; } var d = new List <Drawable>(); var image = await GetBitmap(element.BackgroundImage); d.Add(new BitmapDrawable(image)); var drawable = new GradientDrawable(); drawable.SetShape(ShapeType.Rectangle); drawable.SetStroke((int)Element.BorderWidth, Element.BorderColor.ToAndroid()); drawable.SetColor(Android.Graphics.Color.Transparent); d.Add(drawable); var layer = new LayerDrawable(d.ToArray()); layer.SetLayerInset(d.Count - 1, 0, 0, 0, 0); Control.SetBackground(layer); }
public CustomEntryRenderer(Context context) : base(context) { _gradientDrawable = new GradientDrawable(); _gradientDrawable.SetShape(ShapeType.Rectangle); }
public override Dialog OnCreateDialog(Bundle savedInstanceState) { b = new AlertDialog.Builder(context); availiableTypes = updatedColumn.GetAvailiableColumnChangeTypes(); dialogLayout = context.LayoutInflater.Inflate(Resource.Layout.ColumnEditTypeChange, null); GridLayout grid = dialogLayout.FindViewById <GridLayout>(Resource.Id.gridLayoutChangeTypes); float imageSize = context.Resources.GetDimension(Resource.Dimension.workplace_image_size); foreach (ColumnController.ColumnType type in availiableTypes) { LinearLayout addlayout = context.LayoutInflater.Inflate(Resource.Layout.ColumnTypeImageLayout, grid, false) .FindViewById <LinearLayout>(Resource.Id.linearLayoutType); ImageView image = (ImageView)addlayout.GetChildAt(0); int typeint = (int)type; GradientDrawable g = new GradientDrawable(); g.SetCornerRadius(imageSize / 3); g.SetColor(DatabaseController.colors[(int)type % DatabaseController.colors.Length]); image.Background = g; image.SetColorFilter(Color.White); switch (type) { case ColumnController.ColumnType.CHOICE: image.SetImageResource(Resource.Drawable.icons_menu_32); break; case ColumnController.ColumnType.DATE: image.SetImageResource(Resource.Drawable.icons_calendar_48); break; case ColumnController.ColumnType.IMAGE: image.SetImageResource(Resource.Drawable.icons_picture_32); break; case ColumnController.ColumnType.NUMBER: image.SetImageResource(Resource.Drawable.icons_bars_30); break; case ColumnController.ColumnType.TEXT: image.SetImageResource(Resource.Drawable.icons_text_30); break; } String title = type.ToString().ToLower(); char ch = title[0]; title.Remove(0); TextView titleText = addlayout.FindViewById <TextView>(Resource.Id.textViewType); titleText.Text = "" + char.ToUpper(ch) + title; image.Id = (int)type; image.SetOnClickListener(this); grid.AddView(addlayout); } b.SetView(dialogLayout); b.SetNegativeButton("Cancel", this); b.SetNeutralButton("Delete", this); return(b.Create()); }
public EbXLabelRenderer(Context context) : base(context) { drawable = new GradientDrawable(); }
public void OnClick(View v) { GradientDrawable backgroundShape; switch (v.Id) { case Resource.Id.relativeLayoutDelete: Android.Support.V7.App.AlertDialog.Builder builder = new Android.Support.V7.App.AlertDialog.Builder(this); builder.SetMessage(Resources.GetString(Resource.String.remove_database_string_question)); builder.SetNegativeButton("Cancel", this); builder.SetPositiveButton("Delete", this); builder.Create().Show(); break; case Resource.Id.linearLayoutImagePicker: if (selectedDrawable != null) { selectedDrawable.SetBackgroundColor(Color.Transparent); selectedDrawable.ClearColorFilter(); } selectedDrawable = (ImageView)v; selecteddrawable = imagePicker.IndexOfChild(selectedDrawable); backgroundShape = new GradientDrawable(); if (selectedcolor > -1) { backgroundShape.SetColor(DatabaseController.colors[selectedcolor].ToArgb()); } else { backgroundShape.SetColor(Color.Black); } backgroundShape.SetCornerRadius(imageSize / 8); selectedDrawable.Background = backgroundShape; selectedDrawable.SetColorFilter(Color.White); break; case Resource.Id.linearlayoutColorPicker: if (selectedColor != null) { selectedColor.SetColorFilter(DatabaseController.colors[selectedcolor]); } selectedColor = (ImageView)v; selectedcolor = colorPicker.IndexOfChild(selectedColor); selectedColor.SetImageResource(Resource.Drawable.icons_checkmark); selectedColor.SetColorFilter(Color.White); backgroundShape = new GradientDrawable(); if (selectedcolor > -1) { backgroundShape.SetColor(DatabaseController.colors[selectedcolor].ToArgb()); } else { backgroundShape.SetColor(Color.Black); } backgroundShape.SetCornerRadius(imageSize / 8); if (selectedDrawable != null) { selectedDrawable.Background = backgroundShape; } if (selectedcolor > -1) { SupportActionBar.SetBackgroundDrawable(new ColorDrawable(DatabaseController.colors[selectedcolor])); } else { SupportActionBar.SetBackgroundDrawable(new ColorDrawable(Color.Black)); } break; } }
public EbXDatePickerRenderer(Context context) : base(context) { drawable = new GradientDrawable(); }
public static void SetOrientation(this GradientDrawable drawable, float angle) { drawable.SetOrientation((double)angle); }
public ExtendedEntryRenderer() { var background = new GradientDrawable(); }
protected override void OnInitializeBorderView() { gradientDrawable = new GradientDrawable(); }
public static void UpdateBackground(BorderLayout 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)); if (Android.OS.Build.VERSION.SdkInt < Android.OS.BuildVersionCodes.JellyBean) { view.SetBackgroundDrawable(ld); } else { view.SetBackground(ld); } } else { if (Android.OS.Build.VERSION.SdkInt < Android.OS.BuildVersionCodes.JellyBean) { view.SetBackgroundDrawable(backgroundDrawable); } else { view.SetBackground(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)); }
void updateBackground() { var location = WuClient.Shared.Selected; var random = location == null || Settings.RandomBackgrounds; var gradients = location.GetTimeOfDayGradient(random); using (var gd = new GradientDrawable(GradientDrawable.Orientation.TopBottom, gradients.Item1.ToArray())) { gd.SetCornerRadius(0f); if (viewPager.Background == null) { viewPager.Background = gd; Window.SetStatusBarColor(gradients.Item1 [0]); Window.SetNavigationBarColor(gradients.Item1 [1]); } else { var backgrounds = new Drawable [2]; backgrounds [0] = viewPager.Background; backgrounds [1] = gd; var crossfader = new TransitionDrawable(backgrounds); viewPager.Background = crossfader; crossfader.StartTransition(1000); var statusBarAnimator = ValueAnimator.OfArgb(Window.StatusBarColor, gradients.Item1 [0]); statusBarAnimator.SetDuration(1000); statusBarAnimator.SetInterpolator(new AccelerateDecelerateInterpolator()); statusBarAnimator.Update += (sender, e) => { var val = e.Animation.AnimatedValue as Java.Lang.Integer; var color = new Color((int)val); Window.SetStatusBarColor(color); }; var naviationBarAnimator = ValueAnimator.OfArgb(Window.NavigationBarColor, gradients.Item1 [1]); naviationBarAnimator.SetDuration(1000); naviationBarAnimator.SetInterpolator(new AccelerateDecelerateInterpolator()); naviationBarAnimator.Update += (sender, e) => { var val = e.Animation.AnimatedValue as Java.Lang.Integer; var color = new Color((int)val); Window.SetNavigationBarColor(color); }; statusBarAnimator.Start(); naviationBarAnimator.Start(); } } }