void UpdateSelectedColor()
        {
            var color = Android.Graphics.Color.Rgb(180, 180, 180);

            if (Element.SelectedColor != Xamarin.Forms.Color.Default)
            {
                color = Element.SelectedColor.ToAndroid();
            }

            Control.Selector = DrawableUtility.CreateRipple(color);
        }
Beispiel #2
0
 void UpdateSelectedColor()
 {
     if (CellParent != null && CellParent.SelectedColor != Xamarin.Forms.Color.Default)
     {
         _selectedColor.Color = CellParent.SelectedColor.MultiplyAlpha(0.5).ToAndroid();
         _ripple.SetColor(DrawableUtility.GetPressedColorSelector(CellParent.SelectedColor.ToAndroid()));
     }
     else
     {
         _selectedColor.Color = Android.Graphics.Color.Argb(125, 180, 180, 180);
         _ripple.SetColor(DrawableUtility.GetPressedColorSelector(Android.Graphics.Color.Rgb(180, 180, 180)));
     }
 }
Beispiel #3
0
        protected virtual void CreateContentView()
        {
            var layoutInflater = (LayoutInflater)_Context.GetSystemService(Context.LayoutInflaterService);
            var contentView    = layoutInflater.Inflate(Resource.Layout.CellBaseView, this, true);

            contentView.LayoutParameters = new ViewGroup.LayoutParams(-1, -1);

            IconView         = contentView.FindViewById <ImageView>(Resource.Id.CellIcon);
            TitleLabel       = contentView.FindViewById <TextView>(Resource.Id.CellTitle);
            DescriptionLabel = contentView.FindViewById <TextView>(Resource.Id.CellDescription);
            ContentStack     = contentView.FindViewById <LinearLayout>(Resource.Id.CellContentStack);
            AccessoryStack   = contentView.FindViewById <LinearLayout>(Resource.Id.CellAccessoryView);
            HintLabel        = contentView.FindViewById <TextView>(Resource.Id.CellHintText);

            _backgroundColor = new ColorDrawable();
            _selectedColor   = new ColorDrawable(Android.Graphics.Color.Argb(125, 180, 180, 180));

            var sel = new StateListDrawable();

            sel.AddState(new int[] { global::Android.Resource.Attribute.StateSelected }, _selectedColor);
            sel.AddState(new int[] { -global::Android.Resource.Attribute.StateSelected }, _backgroundColor);
            sel.SetExitFadeDuration(250);
            sel.SetEnterFadeDuration(250);

            var rippleColor = Android.Graphics.Color.Rgb(180, 180, 180);

            if (CellParent.SelectedColor != Xamarin.Forms.Color.Default)
            {
                rippleColor = CellParent.SelectedColor.ToAndroid();
            }

            _ripple = DrawableUtility.CreateRipple(rippleColor, sel);

            Background = _ripple;

            _defaultTextColor = new Android.Graphics.Color(TitleLabel.CurrentTextColor);
            _defaultFontSize  = TitleLabel.TextSize;

            if (!String.IsNullOrEmpty(Cell.AutomationId))
            {
                contentView.ContentDescription = Cell.AutomationId;
            }
        }