Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. public class CustomSliderRenderer : SliderRenderer
  2. {
  3. /// <summary>
  4. /// Instantiate a CustomSliderRenderer
  5. /// </summary>
  6. /// <param name="context">The context to use</param>
  7. public CustomSliderRenderer(Context context)
  8. : base(context) { }
  9.  
  10. /// <summary>
  11. /// Called when the Slider changes
  12. /// </summary>
  13. /// <param name="e">The details of the change</param>
  14. protected override void OnElementChanged(ElementChangedEventArgs<Slider> e)
  15. {
  16. base.OnElementChanged(e);
  17.  
  18. if (!(e.OldElement is null) || e.NewElement is null)
  19. return;
  20.  
  21. // The line colour to the left of the image
  22. Control.ProgressTintList = ColorStateList.ValueOf(Color.Black.ToAndroid());
  23. Control.ProgressTintMode = PorterDuff.Mode.SrcIn;
  24.  
  25. // The line colour to the right of the image
  26. Control.ProgressBackgroundTintList = ColorStateList.ValueOf(Color.Black.ToAndroid());
  27. Control.ProgressBackgroundTintMode = PorterDuff.Mode.SrcIn;
  28. }
  29.  
  30. /// <summary>
  31. /// Called when the Slider is layed out.
  32. /// </summary>
  33. /// <param name="changed">True if the layout has changed, else false</param>
  34. /// <param name="left">The left of the Slider</param>
  35. /// <param name="top">The top of the Slider</param>
  36. /// <param name="right">The right of the Slider</param>
  37. /// <param name="bottom">The bottom of the Slider</param>
  38. protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
  39. {
  40. base.OnLayout(changed, left, top, right, bottom);
  41.  
  42. if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean && !(Control is null))
  43. {
  44. var thumb = Control.Thumb;
  45.  
  46. int thumbTop = Control.Height / 2 - thumb.IntrinsicHeight / 2;
  47.  
  48. thumb.SetBounds(thumb.Bounds.Left, thumbTop, thumb.Bounds.Left + thumb.IntrinsicWidth, thumbTop + thumb.IntrinsicHeight);
  49. }
  50. }
  51. }
  52.  
  53. <Slider
  54. Grid.Row="7"
  55. Grid.Column="0"
  56. Grid.ColumnSpan="2"
  57. x:Name="DaysAbandonedVisible"
  58. Value="{Binding DaysAbandonedVisible}"
  59. Maximum="60"
  60. Minimum="0"
  61. ThumbImageSource="Slider.png"/>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement