SwitchMaterial set checked immediately

Viewed 75

I have following SwitchMaterial component:

<com.google.android.material.switchmaterial.SwitchMaterial
     android:id="@+id/my_toggle"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     />

On activity creation, I want to set the switcher to true/false, based on the database value:

@Override
protected void onCreate(Bundle savedInstanceState) {
     //***
     myToggle.setChecked(defaultValue);
}

The problem is, that when the activity is created, I can see the component to toggle to the state that I set. Is it possible to set the state immediately - without running toogle animation? For example, in this third party library, it can be achieved by setCheckedImmediately(). However, I can see no such option in SwitchMaterial.

0 Answers
Related