What is the difference between these 2 objects (SwitchCompat and SwitchMaterial)? I have tried them and visually they are identical.
By the way, why did they remove the Switch class? Do you know which UI element is supposed to replace it in the future?

The
SwitchMaterial:SwitchCompatWidget.MaterialComponents.CompoundButton.Switchas default style, using the colors defined in theTheme.MaterialComponents(likecolorSecondary,colorSurfaceandcolorOnSurface) and applying the Elevation Overlays in dark mode.The
SwitchCompat:Widget.AppCompat.CompoundButton.Switchas default styleThe
Switchclass is not removed. It is provided by the android framework like other widgets asButton,TextView.. and the appcompat and material components libraries provide an updated version of them (likeAppCompatButton,MaterialButton...).There is a different with these widgets. Using an
AppCompattheme there is theAppCompatViewInflaterthat automatically replaces all usages of core Android widgets inflated from layout files by the AppCompat extensions of those widgets (for example aButtonis replaced byAppCompatButton).Using the
Theme.MaterialComponentsthere is theMaterialComponentsViewInflaterthat replaces some framework widgets with Material Components ones at inflation time, provided a Material Components theme is in use (for example aButtonis replaced byMaterialButton).It is NOT true for the
SwitchMaterialand theSwitchCompat.The reason for that is due to the AppCompatSwitchCompatnot actually extending from the frameworkSwitchclass.