title: Custom Android switch track 'animation'
body: <p>I've created a basic custom <code>Switch</code>, as defined below.</p>
  
  <pre><code>&lt;Switch
          android:id="@+id/availSwitch"
          android:layout_width="wrap_content"
          android:switchMinWidth="110dp"
          android:layout_height="wrap_content"
          android:track="@drawable/switch_track"
          android:thumb="@drawable/thumb"/&gt;
  </code></pre>
  
  <p>The <code>@drawable/thumb</code> is a simple PNG which works fine.</p>
  
  <p>The <code>@drawable/switch_track</code> is defined below. <code>@drawable/trackon</code> and <code>@drawable/trackoff</code> are PNG's.</p>
  
  <pre><code>&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;item android:state_checked="false" android:drawable="@drawable/trackoff" /&gt;
      &lt;item android:state_checked="true"  android:drawable="@drawable/trackon" /&gt;
      &lt;item                               android:drawable="@drawable/trackoff" /&gt;
  
  &lt;/selector&gt;
  </code></pre>
  
  <p>This switch looks and works as intended for the most part, but is there some way to 'animate' the track as the thumb travels over it on user drag? Either fade between checked and unchecked, or preferably change 'behind' the thumb.</p>
  
  <p>The current behaviour is shown below.</p>
  
  <p><a href="https://i.stack.imgur.com/Hqkk0.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/Hqkk0.gif" alt="Current behaviour"></a></p>