5

In the material design guide there is a section called "Display processing status" where we see a video of a Switch with a progress indicator on the thumb.

https://material.io/design/components/selection-controls.html#switches

Because a switch shows the actual status of something, sometimes there is a delay in its change of state. In such cases, a processing status animation can be used.

A processing status is an animation on the thumb of the switch. For example, it can be used when a switch that controls a hardware feature experiences a delay before its final status can be confirmed.

How can I achieve such an effect? is that part of the normal CompatSwitch? Is there a library that does this?

Community
  • 1
  • 1
Daniel Brown
  • 1,134
  • 1
  • 13
  • 27

2 Answers2

7

This is just an idea that may help you. You can use the custom image/drawable inside switches with help of switch thumb property

<Switch
android:id="@+id/switch_one"
. . .
android:track="@drawable/switch_track_custom"
android:thumb="@drawable/switch_thumb_custom"/>

For state change, you can use Selecter. this blog gives you a good idea.

Here are some other blog and libraries

Mehul Solanki
  • 1,147
  • 11
  • 15
0

However, I think that video is just to demonstrate 'DO NOT DO THIS'. Because it clearly says

Don't demonstrate status by animating the thumb of a switch.

Luxi Liu
  • 7,878
  • 2
  • 14
  • 13