2

I'm trying to style my RadioButton as normal buttons and support color change on the buttons, with ripple effect when one of them is clicked.

What happens now, is that all buttons are grey, they ripple in purple when they are clicked but don't change their color to purple permenently - which is the problem I'm trying to solve.

Thisi s how he buttons look right now

enter image description here

RadioButton in whatever.xml

<RadioButton
    style="@style/Widget.AppCompat.Button"
    android:id="@+id/product_size2"
    android:layout_width="48dp"
    android:layout_height="48dp"
    android:text="S"
    android:button="@null"
    android:textColor="@color/material_light_white"/>

Relevant items in style.xml

<item name="android:colorButtonNormal">@color/material_grey_700</item>
<item name="android:colorControlHighlight">@color/material_purple_500</item>

I want the buttons to stay purple when they are chosen - solution?

bluesummers
  • 11,365
  • 8
  • 72
  • 108

1 Answers1

0

radiobutton_background.xml:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
      <item android:state_checked="true" android:drawable="@color/material_purple_500" />
      <item android:state_checked="false" android:drawable="@color/material_grey_700" />
</selector>

And use it as a Background:

android:background="@drawable/radiobutton_background" />
Vladyslav Matviienko
  • 10,610
  • 4
  • 33
  • 52
  • Doesn't work, what happens is the background overlays the style, effectively killing the style (creates a cube with no elevation) and no ripple effect – bluesummers Nov 03 '16 at 14:09