public override void draw(android.graphics.Canvas canvas) { bool vertical = mVertical; int extent = mExtent; int range = mRange; bool drawTrack_1 = true; bool drawThumb_1 = true; if (extent <= 0 || range <= extent) { drawTrack_1 = vertical ? mAlwaysDrawVerticalTrack : mAlwaysDrawHorizontalTrack; drawThumb_1 = false; } android.graphics.Rect r = getBounds(); if (canvas.quickReject(r.left, r.top, r.right, r.bottom, android.graphics.Canvas.EdgeType .AA)) { return; } if (drawTrack_1) { drawTrack(canvas, r, vertical); } if (drawThumb_1) { int size = vertical ? r.height() : r.width(); int thickness = vertical ? r.width() : r.height(); int length = Sharpen.Util.Round((float)size * extent / range); int offset = Sharpen.Util.Round((float)(size - length) * mOffset / (range - extent )); // avoid the tiny thumb int minLength = thickness * 2; if (length < minLength) { length = minLength; } // avoid the too-big thumb if (offset + length > size) { offset = size - length; } drawThumb(canvas, r, offset, length, vertical); } }