コード例 #1
0
        private RippleDrawable GetRippleDrawable()
        {
            RippleDrawable rippleDrawable = null;

            if (_button.ButtonType == MaterialButtonType.Text || _button.ButtonType == MaterialButtonType.Outlined)
            {
                if (_button.ButtonType == MaterialButtonType.Outlined)
                {
                    rippleDrawable = _withIcon ? MaterialHelper.GetDrawableCopyFromResource <RippleDrawable>(Resource.Drawable.drawable_ripple_outlined_with_icon) : MaterialHelper.GetDrawableCopyFromResource <RippleDrawable>(Resource.Drawable.drawable_ripple_outlined);
                }
                else
                {
                    rippleDrawable = MaterialHelper.GetDrawableCopyFromResource <RippleDrawable>(Resource.Drawable.drawable_ripple_text);
                }
            }

            else
            {
                rippleDrawable = _withIcon ? MaterialHelper.GetDrawableCopyFromResource <RippleDrawable>(Resource.Drawable.drawable_ripple_with_icon) : MaterialHelper.GetDrawableCopyFromResource <RippleDrawable>(Resource.Drawable.drawable_ripple);
            }

            var maskDrawable = rippleDrawable.FindDrawableByLayerId(Android.Resource.Id.Mask) as InsetDrawable;
            var rippleMaskGradientDrawable = maskDrawable.Drawable as GradientDrawable;

            rippleMaskGradientDrawable.SetCornerRadius(_cornerRadius);

            return(rippleDrawable);
        }