code: private void init(Context context, AttributeSet attrs){
          TypedArray attributeArray = context.obtainStyledAttributes(
                  attrs,
                  R.styleable.DiscreteSlider);
  
          try {
              tickMarkCount = attributeArray.getInteger(R.styleable.DiscreteSlider_tickMarkCount, 5);
              tickMarkRadius = attributeArray.getDimension(R.styleable.DiscreteSlider_tickMarkRadius, 8);
              position = attributeArray.getInteger(R.styleable.DiscreteSlider_position, 0);
              horizontalBarThickness = attributeArray.getDimension(R.styleable.DiscreteSlider_horizontalBarThickness, 4);
              backdropFillColor = attributeArray.getColor(R.styleable.DiscreteSlider_backdropFillColor, Color.GRAY);
              backdropStrokeColor = attributeArray.getColor(R.styleable.DiscreteSlider_backdropStrokeColor, Color.GRAY);
              backdropStrokeWidth = attributeArray.getDimension(R.styleable.DiscreteSlider_backdropStrokeWidth, 1);
              thumb = attributeArray.getDrawable(R.styleable.DiscreteSlider_thumb);
              progressDrawable = attributeArray.getDrawable(R.styleable.DiscreteSlider_progressDrawable);
          } finally {
              attributeArray.recycle();
          }
  
          View view = inflate(context, R.layout.discrete_slider, this);
          discreteSliderBackdrop = (DiscreteSliderBackdrop)view.findViewById(R.id.discrete_slider_backdrop);
          discreteSeekBar = (DiscreteSeekBar)view.findViewById(R.id.discrete_seek_bar);
  
          setTickMarkCount(tickMarkCount);
          setTickMarkRadius(tickMarkRadius);
          setHorizontalBarThickness(horizontalBarThickness);
          setBackdropFillColor(backdropFillColor);
          setBackdropStrokeColor(backdropStrokeColor);
          setBackdropStrokeWidth(backdropStrokeWidth);
          setPosition(position);
          setThumb(thumb);
          setProgressDrawable(progressDrawable);
  
          discreteSeekBar.setPadding(discreteSeekBarLeftPadding,0,discreteSeekBarRightPadding,0);
  
          discreteSeekBar.setOnDiscreteSeekBarChangeListener(new DiscreteSeekBar.OnDiscreteSeekBarChangeListener() {
              @Override
              public void onPositionChanged(int position) {
                  if(onDiscreteSliderChangeListener != null){
                      onDiscreteSliderChangeListener.onPositionChanged(position);
                      setPosition(position);
                  }
              }
          });
      }
docs: region Helper Methods