Beispiel #1
0
        public void OnDetachedIfNotDisposed()
        {
            _track.SetTintList(null);
            _thumb.SetTintList(null);

            //restore like default color but not completely.
            var color       = Xamarin.Forms.Color.Accent.ToAndroid();
            var trackColors = new ColorStateList(new int[][]
            {
                new int[] { global::Android.Resource.Attribute.StateChecked },
                new int[] { -global::Android.Resource.Attribute.StateChecked },
            },
                                                 new int[] {
                Android.Graphics.Color.Argb(76, color.R, color.G, color.B),
                Android.Graphics.Color.Argb(76, 50, 50, 50)
            });

            _orgTrack.SetTintList(trackColors);
            _orgTrack.SetState(_track.GetState());
            _orgThumb.SetState(_thumb.GetState());
            _orgBackground.SetState(_background.GetState());

            _aSwitch.TrackDrawable = _orgTrack;
            _aSwitch.ThumbDrawable = _orgThumb;
            _aSwitch.Background    = _orgBackground;
        }