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 
	protected void onLayout(final boolean changed, final int left, final int top, final int right, final int bottom) {
		super.onLayout(changed, left, top, right, bottom);
 
		mThumbPosition = isChecked() ? getThumbScrollRange() : 0;
 
		final int switchRight = getWidth() - getPaddingRight();
		final int switchLeft = switchRight - mSwitchWidth;
		int switchTop = 0;