I want to change the color of the active toggle button. But just the change of the rippleColor makes a difference. I wish to customize the background color of the active button and the text color.
<style name="ToggleButtonGroupStyle" parent="Widget.MaterialComponents.Button.OutlinedButton">
<item name="rippleColor">@color/colorAccent</item>
</style>
In the following toggleButtonGroup I used this style from above:
<com.google.android.material.button.MaterialButtonToggleGroup
android:id="@+id/priority_btn_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentLeft="true"
app:selectionRequired="true"
app:singleSelection="true"
app:checkedButton="@+id/btn_one"
>
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_one"
style="@style/ToggleButtonGroupStyle"
android:layout_width="@dimen/priority_btn_width"
android:layout_height="wrap_content"
android:shadowColor="@color/project_text"
android:text="0" />
<com.google.android.material.button.MaterialButton
style="@style/ToggleButtonGroupStyle"
android:layout_width="@dimen/priority_btn_width"
android:layout_height="wrap_content"
android:text="!" />
<com.google.android.material.button.MaterialButton
style="@style/ToggleButtonGroupStyle"
android:layout_width="@dimen/priority_btn_width"
android:layout_height="wrap_content"
android:text="!!" />
<com.google.android.material.button.MaterialButton
style="@style/ToggleButtonGroupStyle"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:text="!!!" />
</com.google.android.material.button.MaterialButtonToggleGroup>
Could anybody give me a hint what the problem here is? Thanks :)
The background color of the checked buttons is based on the
colorPrimary
attribute.You can use:
with:
or you can use a custom style with:
with: