How to show process status on a switch in android?
Asked Answered
G

2

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?

Galliot answered 20/5, 2019 at 12:7 Comment(1)
Did you found how can be done this effect?Isotherm
T
6

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

Timofei answered 20/5, 2019 at 12:23 Comment(0)
L
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.

Literality answered 17/6, 2021 at 11:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.