Code example for Layout

Methods: draw, getHeight, getWidth

0
mTextPaint.drawableState = getDrawableState();
 
        final Layout switchText = getTargetCheckedState() ? mOnLayout : mOffLayout;
 
        canvas.translate((thumbLeft + thumbRight) / 2 - switchText.getWidth() / 2, (switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2);
        switchText.draw(canvas);
 
        canvas.restore();
    } 
 
    @Override 
    public int getCompoundPaddingRight() { 
        int padding = super.getCompoundPaddingRight() + mSwitchWidth;
        if (!TextUtils.isEmpty(getText())) {
            padding += mSwitchPadding;
        } 
        return padding;
    } 
 
    private int getThumbScrollRange() {