public void onDrawScrollBar(Canvas canvas,int range,int offset,int extent,int alpha){
  float strokeRadius=mPaint.getStrokeWidth() / 2;
  float extraAngle=0;
  float offsetY=mOffset.y;
  if (offsetY > 0) {
    float targetHeight=mScreenRadius - offsetY - strokeRadius;
    double targetRadians=-Math.asin(targetHeight / mScreenRadius);
    float targetAngle=(float)(360 * targetRadians / Math.PI / 2);
    extraAngle=MathUtils.constrain(targetAngle - START_ANGLE,0f,-START_ANGLE);
  }
 else   if (offsetY < 0) {
    float targetHeight=mScreenRadius + offsetY - strokeRadius;
    double targetRadians=Math.asin(targetHeight / mScreenRadius);
    float targetAngle=(float)(360 * targetRadians / Math.PI / 2);
    extraAngle=MathUtils.constrain(START_ANGLE + SWEEP_ANGLE - targetAngle,0f,START_ANGLE + SWEEP_ANGLE);
  }
  float startAngle=MathUtils.constrain(START_ANGLE + extraAngle,START_ANGLE,0);
  float sweepAngle=MathUtils.constrain(SWEEP_ANGLE - 2 * extraAngle,0,SWEEP_ANGLE);
  float minSweep=MIN_SWEEP * sweepAngle / SWEEP_ANGLE;
  float thumbSweep=(extent * sweepAngle) / range;
  thumbSweep=MathUtils.constrain(thumbSweep,minSweep,sweepAngle);
  float thumbRotation=(sweepAngle - thumbSweep) * (offset) / (range - extent);
  float opacity=alpha / 255f;
  if (DesignConfig.DEBUG_SCROLLBAR && offsetY != 0) {
    Log.v(TAG,"offset " + offsetY + ", extra "+ extraAngle+ ", scrollbar ("+ startAngle+ ","+ sweepAngle+ "), with opacity "+ opacity);
  }
  canvas.save();
  canvas.translate(-mOffset.x,-mOffset.y);
  if (mIsRound) {
    setColorWithOpacity(mPaint,mBgColor,opacity);
    canvas.drawArc(mOval,startAngle,sweepAngle,false,mPaint);
    setColorWithOpacity(mPaint,mSweepColor,opacity);
    canvas.rotate(thumbRotation,mOval.centerX(),mOval.centerY());
    canvas.drawArc(mOval,startAngle,thumbSweep,false,mPaint);
  }
 else {
    float x=mOval.right;
    setColorWithOpacity(mPaint,mBgColor,opacity);
    float startY=getY(startAngle,x);
    float length=getY(startAngle + sweepAngle,x) - startY;
    canvas.drawLine(x,startY,x,startY + length,mPaint);
    setColorWithOpacity(mPaint,mSweepColor,opacity);
    float start=startY + (thumbRotation / sweepAngle) * length;
    float end=startY + ((thumbRotation + thumbSweep) / sweepAngle) * length;
    canvas.drawLine(x,start,x,end,mPaint);
  }
  canvas.restore();
}

public void onDrawScrollBar ( Canvas canvas , int range , int offset , int extent , int alpha ) { float strokeRadius = mPaint . getStrokeWidth ( ) / 2 ; float extraAngle = 0 ; float offsetY = mOffset . y ; if ( offsetY > 0 ) { float targetHeight = mScreenRadius - offsetY - strokeRadius ; double targetRadians = - Math . asin ( targetHeight / mScreenRadius ) ; float targetAngle = ( float ) ( 360 * targetRadians / Math . PI / 2 ) ; extraAngle = MathUtils . constrain ( targetAngle - START_ANGLE , 0f , - START_ANGLE ) ; } else if ( offsetY < 0 ) { float targetHeight = mScreenRadius + offsetY - strokeRadius ; double targetRadians = Math . asin ( targetHeight / mScreenRadius ) ; float targetAngle = ( float ) ( 360 * targetRadians / Math . PI / 2 ) ; extraAngle = MathUtils . constrain ( START_ANGLE + SWEEP_ANGLE - targetAngle , 0f , START_ANGLE + SWEEP_ANGLE ) ; } float startAngle = MathUtils . constrain ( START_ANGLE + extraAngle , START_ANGLE , 0 ) ; float sweepAngle = MathUtils . constrain ( SWEEP_ANGLE - 2 * extraAngle , 0 , SWEEP_ANGLE ) ; float minSweep = MIN_SWEEP * sweepAngle / SWEEP_ANGLE ; float thumbSweep = ( extent * sweepAngle ) / range ; thumbSweep = MathUtils . constrain ( thumbSweep , minSweep , sweepAngle ) ; float thumbRotation = ( sweepAngle - thumbSweep ) * ( offset ) / ( range - extent ) ; float opacity = alpha / 255f ; if ( DesignConfig . DEBUG_SCROLLBAR && offsetY != 0 ) { Log . v ( TAG , "offset " + offsetY + ", extra " + extraAngle + ", scrollbar (" + startAngle + "," + sweepAngle + "), with opacity " + opacity ) ; } canvas . save ( ) ; canvas . translate ( - mOffset . x , - mOffset . y ) ; if ( mIsRound ) { setColorWithOpacity ( mPaint , mBgColor , opacity ) ; canvas . drawArc ( mOval , startAngle , sweepAngle , false , mPaint ) ; setColorWithOpacity ( mPaint , mSweepColor , opacity ) ; canvas . rotate ( thumbRotation , mOval . centerX ( ) , mOval . centerY ( ) ) ; canvas . drawArc ( mOval , startAngle , thumbSweep , false , mPaint ) ; } else { float x = mOval . right ; setColorWithOpacity ( mPaint , mBgColor , opacity ) ; float startY = getY ( startAngle , x ) ; float length = getY ( startAngle + sweepAngle , x ) - startY ; canvas . drawLine ( x , startY , x , startY + length , mPaint ) ; setColorWithOpacity ( mPaint , mSweepColor , opacity ) ; float start = startY + ( thumbRotation / sweepAngle ) * length ; float end = startY + ( ( thumbRotation + thumbSweep ) / sweepAngle ) * length ; canvas . drawLine ( x , start , x , end , mPaint ) ; } canvas . restore ( ) ; }
call this in hidden api ondrawverticalscrollbar .
