protected override void OnAttached() { if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.JellyBean) { _thumbColor = (Color)Element.GetValue(XECCSwitchEffect.ThumbColorProperty); _trueColor = (Color)Element.GetValue(XECCSwitchEffect.TrueColorProperty); _falseColor = (Color)Element.GetValue(XECCSwitchEffect.FalseColorProperty); _falseColorDarker = _falseColor.AddLuminosity(-0.25); _trueColorDarker = _trueColor.AddLuminosity(-0.25); ((SwitchCompat)Control).CheckedChange += OnCheckedChange; ((SwitchCompat)Control).TrackDrawable.SetColorFilter(_falseColorDarker.ToAndroid(), PorterDuff.Mode.Multiply); ((SwitchCompat)Control).ThumbDrawable.SetColorFilter(_thumbColor.ToAndroid(), PorterDuff.Mode.Multiply); // to change the colour of the thumb-drawable to the 'true' (or 'false') colour, enable the line below (and disable the one above) // ((SwitchCompat)Control).ThumbDrawable.SetColorFilter(_trueColor.ToAndroid(), PorterDuff.Mode.Multiply); } }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; Color background_color = Color.FromHex(CrossSettings.Current.GetValueOrDefault("backColor", Color.White.ToHex())); Android.Graphics.Color statues_bar = background_color.AddLuminosity(-.07).ToAndroid(); Window.SetStatusBarColor(statues_bar); this.SetStatusBarColor(statues_bar); MessagingCenter.Subscribe <ColorPickerCell, Color>(this, "ChangeBackColor", (sender, arg) => { // do something whenever the "ChangeBackColor" message is sent Window.SetStatusBarColor(arg.AddLuminosity(-.07).ToAndroid()); this.SetStatusBarColor(arg.AddLuminosity(-.07).ToAndroid()); }); base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); LoadApplication(new App()); }