How to shrink SwitchCompat width?
<p>I want to reduce my Switch's width. The current solution in <a href="https://stackoverflow.com/q/10173590/3286489">How to change the size of a Switch Widget</a> and <a href="https://stackoverflow.com/q/16599327/3286489">How to change Width of Android&#39;s Switch track?</a> is not solving my problem. <code>android:switchMinWidth</code> just defined the minWidth, but I want it to be smaller than <code>2 x thumbWidth</code> size.</p>

<p>I dig into the <a href="https://android.googlesource.com/platform/frameworks/support/+/f91071f/v7/appcompat/src/android/support/v7/widget/SwitchCompat.java" rel="noreferrer"><code>SwitchCompat</code> class' <code>onMeasure()</code> function</a>. The way the width is defined is as below.</p>

<pre><code>    // Adjust left and right padding to ensure there's enough room for the
    // thumb's padding (when present).
    int paddingLeft = padding.left;
    int paddingRight = padding.right;
    if (mThumbDrawable != null) {
        final Rect inset = DrawableUtils.getOpticalBounds(mThumbDrawable);
        paddingLeft = Math.max(paddingLeft, inset.left);
        paddingRight = Math.max(paddingRight, inset.right);
    }

    final int switchWidth = Math.max(mSwitchMinWidth,
            2 * mThumbWidth + paddingLeft + paddingRight);
    final int switchHeight = Math.max(trackHeight, thumbHeight);
    mSwitchWidth = switchWidth;
    mSwitchHeight = switchHeight;
</code></pre>

<p>I was considering using negative padding, but then there's this line <code>paddingLeft = Math.max(paddingLeft, inset.left);</code>. I'm not sure how to set the <code>inset</code> to my thumb drawable that has negative value (I don't know what <code>inset</code> or <code>OpticalBounds</code> is. Maybe this should be another stackoverflow question ).</p>

<p>Anyone has idea how I could shrink the width of my SwitchCompat?</p>

<p><strong>Update</strong>
I have filed a request to google on this <a href="https://code.google.com/p/android/issues/detail?id=227184&amp;thanks=227184&amp;ts=1478485498" rel="noreferrer">https://code.google.com/p/android/issues/detail?id=227184&amp;thanks=227184&amp;ts=1478485498</a></p>