You can still use the radio buttons within the group of radio stations and attributes so that each switch looks like a button.
In the xml for each switch, set android:button="@null" so that the dots are not visible. You can add a few add-ons to make them look different.
In the code, install the CheckedChangeListener in your radio group, then find the link to checkedView (RadioButton) with checkedId. In this example, I just changed the background color in the view, but you could add another background too. If the radioButton is not null, then it has already been changed, so I will reset it to its initial state.
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { if (radioButton != null) { radioButton.setBackgroundColor(Color.TRANSPARENT); radioButton.setButtonDrawable(0);
Hope this helps!
Denny schuldt
source share