SwitchPreferenceCompat: android:switchTextOff / switchTextOn doesn't work
<p>I'm trying to display a switchPreference which allows the user to display the distance according to miles or kms. I'm using the SwitchPreferenceCompat support library. According to the library, I can use the textSwitchOff and textSwitchOn to add text to the switch. I just want to add "km" or "miles" to my switch so that the user knows which metric is displayed.</p>

<p>According to <a href="http://developer.android.com/reference/android/support/v7/preference/SwitchPreferenceCompat.html#attr_android:switchTextOff" rel="noreferrer">this doc</a>, all I need is the code below:</p>

<pre><code>&lt;android.support.v7.preference.PreferenceCategory
    android:layout="@layout/preferences_category"
    android:title="Distance" &gt;

    &lt;android.support.v7.preference.SwitchPreferenceCompat android:title="KM or Miles"
        android:key="kmormiles"
        android:switchTextOff="miles"
        android:switchTextOn="km"
        android:defaultValue="true"/&gt;

&lt;/android.support.v7.preference.PreferenceCategory&gt;
</code></pre>

<p>However, the switch just looks like a normal switch, there is no extra text on the switch itself.</p>

<p><a href="https://i.stack.imgur.com/4m8eW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4m8eW.png" alt="enter image description here"></a></p>

<p>How do I get it to display with the textOn and textOff?</p>

<p>I also tried the following:</p>

<pre><code>    addPreferencesFromResource(R.xml.preferences);
    kmormiles = (SwitchPreferenceCompat) findPreference("kmormiles");
    kmormiles.setSwitchTextOff("Km");
    kmormiles.setSwitchTextOn("miles");
</code></pre>

<p>Still doesn't work. I'm trying it on two different genymotion emulators, API 16 and API 21.</p>