How to Implement MaterialButtonToggleGroup: Android Studio

Here are the steps to implement a MaterialButtonToggleGroup:

  1. In the XML file, set app:singleSelection to “true” so that only one button will be selected at a time.
  2. Initialize MaterialButtonToggleGroup and MaterialButton before onCreate(), for example, MaterialButtonToggleGroup buttonToggleGroup and MaterialButton toggleButton.