private void Init(Context context, IAttributeSet attrs, int style) { Resources res = Resources; density = res.DisplayMetrics.Density; TypedArray a = Context.ObtainStyledAttributes(attrs, Resource.Styleable.SlideToAction, style, 0); string tmp = a.GetString(Resource.Styleable.SlideToAction_slideToUnlockText); text = string.IsNullOrEmpty(tmp) ? text : tmp; rx = a.GetDimension(Resource.Styleable.SlideToAction_cornerRadiusX, rx); useDefaultCornerRadiusX = rx == 0; ry = a.GetDimension(Resource.Styleable.SlideToAction_cornerRadiusX, ry); useDefaultCornerRadiusY = ry == 0; backgroundColor = a.GetColor(Resource.Styleable.SlideToAction_slideToUnlockBackgroundColor, backgroundColor); textColor = a.GetColor(Resource.Styleable.SlideToAction_slideToUnlockTextColor, textColor); sliderColor = a.GetColor(Resource.Styleable.SlideToAction_sliderColor, sliderColor); cancelOnYExit = a.GetBoolean(Resource.Styleable.SlideToAction_cancelOnYExit, false); a.Recycle(); mRoundedRectPath = new Path(); mBackgroundPaint = new Paint(PaintFlags.AntiAlias); mBackgroundPaint.SetStyle(Paint.Style.Fill); mBackgroundPaint.Color = backgroundColor; mTextPaint = new Paint(PaintFlags.AntiAlias); mTextPaint.SetStyle(Paint.Style.Fill); mTextPaint.Color = textColor; mTextPaint.SetTypeface(Typeface.Create("Roboto-Thin", TypefaceStyle.Normal)); mSliderPaint = new Paint(PaintFlags.AntiAlias); mSliderPaint.SetStyle(Paint.Style.FillAndStroke); mSliderPaint.Color = sliderColor; mSliderPaint.StrokeWidth = 2 * density; if (!IsInEditMode) { // Edit mode does not support shadow layers // mSliderPaint.setShadowLayer(10.0f, 0.0f, 2.0f, 0xFF000000); //mSliderPaint.setMaskFilter(new EmbossMaskFilter(new float[]{1, 1, 1}, 0.4f, 10, 8.2f)); float[] direction = new float[] { 0.0f, -1.0f, 0.5f }; MaskFilter filter = new EmbossMaskFilter(direction, 0.8f, 15f, 1f); mSliderPaint.SetMaskFilter(filter); //mSliderPaint.setShader(new LinearGradient(8f, 80f, 30f, 20f, Color.RED,Color.WHITE, Shader.TileMode.MIRROR)); //mSliderPaint.setShader(new RadialGradient(8f, 80f, 90f, Color.RED,Color.WHITE, Shader.TileMode.MIRROR)); //mSliderPaint.setShader(new SweepGradient(80, 80, Color.RED, Color.WHITE)); //mSliderPaint.setMaskFilter(new BlurMaskFilter(15, BlurMaskFilter.Blur.OUTER)); } }
protected override void onDraw(Canvas canvas) { canvas.drawColor(unchecked ((int)0xFFDDDDDD)); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(10); EmbossMaskFilter mf = new EmbossMaskFilter(new float[] { 1, 1, 1 }, 128, 16 * 2, 4); paint.setMaskFilter(mf); mf.Dispose(); // paint.setMaskFilter(new SkEmbossMaskFilter(fLight, SkIntToScalar(4)))->unref(); // paint.setShader(new SkColorShader(SK_ColorBLUE))->unref(); paint.setDither(true); canvas.drawCircle(50, 50, 30, paint); paint.Dispose(); }