protected override void DispatchDraw(Android.Graphics.Canvas canvas) { var gradients = new Android.Graphics.LinearGradient(0, 0, 0, Height, this.StarColor.ToAndroid(), this.EndColor.ToAndroid(), Android.Graphics.Shader.TileMode.Mirror); var paint = new Android.Graphics.Paint() { Dither = true }; paint.SetShader(gradients); canvas.DrawPaint(paint); base.DispatchDraw(canvas); }
protected override void DispatchDraw(Android.Graphics.Canvas canvas) { var gradient = Direction == GredientBoxViewDirection.TopToBottom ? new Android.Graphics.LinearGradient(0, 0, 0, Height, StartColor.ToAndroid(), EndColor.ToAndroid(), Android.Graphics.Shader.TileMode.Mirror) : Direction == GredientBoxViewDirection.LeftToRight ? new Android.Graphics.LinearGradient(0, 0, Width, 0, StartColor.ToAndroid(), EndColor.ToAndroid(), Android.Graphics.Shader.TileMode.Mirror) : Direction == GredientBoxViewDirection.TopLeftToBottomRight ? new Android.Graphics.LinearGradient(0, 0, Width, Height, StartColor.ToAndroid(), EndColor.ToAndroid(), Android.Graphics.Shader.TileMode.Mirror) : Direction == GredientBoxViewDirection.TopRightToBottomLeft ? new Android.Graphics.LinearGradient(0, Width, 0, Height, StartColor.ToAndroid(), EndColor.ToAndroid(), Android.Graphics.Shader.TileMode.Mirror) : null; var paint = new Android.Graphics.Paint { Dither = true }; paint.SetShader(gradient); canvas.DrawPaint(paint); base.DispatchDraw(canvas); }
protected override void DispatchDraw(Android.Graphics.Canvas canvas) { #region for Vertical Gradient var gradient = new Android.Graphics.LinearGradient(0, 0, 0, Height, #endregion #region for Horizontal Gradient //var gradient = new Android.Graphics.LinearGradient(0, 0, Width, 0, #endregion this.StartColor.ToAndroid(), this.EndColor.ToAndroid(), Android.Graphics.Shader.TileMode.Mirror); var paint = new Android.Graphics.Paint() { Dither = true, }; paint.SetShader(gradient); canvas.DrawPaint(paint); base.DispatchDraw(canvas); }
protected override void DispatchDraw(Android.Graphics.Canvas canvas) { if (Colors == null) { base.DispatchDraw(canvas); return; } Android.Graphics.LinearGradient gradient; var colors = new int[Colors.Length]; for (int i = 0, l = Colors.Length; i < l; i++) { colors[i] = Colors[i].ToAndroid().ToArgb(); } switch (Mode) { default: gradient = new Android.Graphics.LinearGradient(0, 0, Width, 0, colors, null, Android.Graphics.Shader.TileMode.Mirror); break; case GradientColorStackMode.ToLeft: gradient = new Android.Graphics.LinearGradient(Width, 0, 0, 0, colors, null, Android.Graphics.Shader.TileMode.Mirror); break; case GradientColorStackMode.ToTop: gradient = new Android.Graphics.LinearGradient(0, Height, 0, 0, colors, null, Android.Graphics.Shader.TileMode.Mirror); break; case GradientColorStackMode.ToBottom: gradient = new Android.Graphics.LinearGradient(0, 0, 0, Height, colors, null, Android.Graphics.Shader.TileMode.Mirror); break; case GradientColorStackMode.ToTopLeft: gradient = new Android.Graphics.LinearGradient(Width, Height, 0, 0, colors, null, Android.Graphics.Shader.TileMode.Mirror); break; case GradientColorStackMode.ToTopRight: gradient = new Android.Graphics.LinearGradient(0, Height, Width, 0, colors, null, Android.Graphics.Shader.TileMode.Mirror); break; case GradientColorStackMode.ToBottomLeft: gradient = new Android.Graphics.LinearGradient(Width, 0, 0, Height, colors, null, Android.Graphics.Shader.TileMode.Mirror); break; case GradientColorStackMode.ToBottomRight: gradient = new Android.Graphics.LinearGradient(0, 0, Width, Height, colors, null, Android.Graphics.Shader.TileMode.Mirror); break; } var paint = new Android.Graphics.Paint { Dither = true, }; paint.SetShader(gradient); canvas.DrawPaint(paint); base.DispatchDraw(canvas); }