I want to achieve this look in my app:

My xml code in the activity looks something like that:
<com.google.android.material.button.MaterialButtonToggleGroup
android:id="@+id/toggleGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.google.android.material.button.MaterialButton
android:id="@+id/button1"
... />
<com.google.android.material.button.MaterialButton
android:id="@+id/button2"
... />
<com.google.android.material.button.MaterialButton
android:id="@+id/button3"
... />
</com.google.android.material.button.MaterialButtonToggleGroup>
I migrated to androidx, and used material components in my styles, but for some reason I get a runtime error that says:
Binary XML file: Error inflating class com.google.android.material.button.MaterialButtonToggleGroup
implementation "com.google.android.material:material:1.0.0"
Though, When using com.google.android.material.button.MaterialButton without a group it would work perfectly fine, meaning that I'm using the right styling and gradle implementation.
I tries also the following:
- invalidating cache
- removing and reimporting both
androidx.appcompat:appcompat:1.1.0andcom.google.android.material:material:1.0.0multiple times - closing and reopening android studio
- reimporting the project after closing it
- pumping up minSdkVersion to be 21 instead of 14 (target and compile sdk versions are both 28)
Here are my dependencies (In case some of them are causing some sort of confliction):
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
//Room Persistance Library
def room_version = "2.1.0"
implementation "android.arch.persistence.room:runtime:$room_version"
annotationProcessor "android.arch.persistence.room:compiler:$room_version"
//Lifecycle Libraries from the Android Architecture Components
def lifecyle_version = " 2.1.0"
implementation "android.arch.lifecycle:extensions:$lifecyle_version"
annotationProcessor "android.arch.lifecycle:compiler:$room_version"
//External Libraries:
implementation 'com.github.HITGIF:TextFieldBoxes:1.4.4'
implementation "com.google.android.material:material:1.0.0"
Here is the style I'm using for that activity:
<style name="ThemeNewRoutine" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
Here is the activity element in the manifest file:
<activity
android:name=".Views.NewRoutine.NewRoutineActivity"
android:theme="@style/ThemeNewRoutine">
</activity>
How come com.google.android.material.button.MaterialButton is working perfectly fine BUT com.google.android.material.button.MaterialButtonToggleGroup isn't.
Also, I found out that the following attributes also cannot be resolved when I use them in the style.xml file (even though the parent is Theme.MaterialComponents.Light):
- colorPrimaryVariant
- colorOnPrimary
- colorSecondaryVariant
- colorOnSecondary
- colorOnError
- colorSurface
- colorOnSurface
- colorOnBackground
I don't know if that would cause any confliction but my activity extends AppCompatActivity:
public class NewRoutineActivity extends AppCompatActivity