Questions tagged [android-togglebutton]

A toggle button allows the user to change a setting between two states.

A toggle button allows the user to change a setting between two states. It displays checked/unchecked states as a button with a "light" indicator and by default accompanied with the text "ON" or "OFF".

For more information, see the Toggle Buttons guide.

199 questions
20
votes
8 answers

How to know whether user has changed the state of toggle button?

I have ten toggle buttons. I want to save the state of five of those buttons when clicking the home button. But I want to save it only if the user has made a change to any of the buttons' state. Is there any way to know the change in states without…
nila
  • 3,223
  • 4
  • 18
  • 15
18
votes
6 answers

Android Toggle Button - Material Design

How do I implement the Toggle Buttons as specified in Material Design guidelines here? Is it available out of the box from Android Design Support Library or is there any third party library available?
14
votes
4 answers

Required single selection on MaterialButtonToggleGroup

Is there an option to make the MaterialButtonToggleGroup have a required selected button when using app:singleSelection="true"? When clicking to a different button works fine (all other buttons are deselected), but when you click the same (already…
11
votes
1 answer

selected color of MaterialToggleButton to a solid color

Not able to make the selected color of MaterialToggleButton to a solid color, only a transparent shade of color primary is shown. I tried the below set of code and the out image is shown below. Button theme in styles
9
votes
3 answers

MaterialButtonToggleGroup's child with same width

I want to use MaterialButtonToggleGroup with 2 MaterialButton. I want to display them with same width inside MaterialButtonToggleGroup If I use match_parent then only one button will be displayed and if I use wrap_content they displayed in the…
Sid
  • 199
  • 1
  • 12
7
votes
1 answer

EditText addTextChangedListener only for user input

I have an EditText where I listen for changes in text: editText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public…
user1583209
  • 1,637
  • 3
  • 24
  • 42
6
votes
1 answer

Create Toggle Button Group in Jetpack Compose without Radio Buttons

I am trying to put a button toggle group in my project that behaves similarly to a radio button group, but does not look like a radio button group (ie when one button is selected, the others are deselected). I followed a radio button pattern I found…
6
votes
3 answers

MaterialButtonToggleGroup child's MaterialButton layout_marginStart, layout_marginEnd not working

If i am trying to add margin with layout_marginStart or layout_marginEnd but there is no effect on UI. I am not sure why layout_marginStart, layout_marginEnd not working with MaterialButton when i add them as the child of…
6
votes
0 answers

Android (API Level 28), Invalid Region.Op - only INTERSECT and DIFFERENCE are allowed

I am trying to add a ToggleButton in design mode in Android studio. I am targeting API Level 28 targetSdkVersion 28 My ToggleButton is not showing and I see that error: java.lang.IllegalArgumentException: Invalid Region.Op - only INTERSECT and…
Kevin Amiranoff
  • 13,440
  • 11
  • 59
  • 90
6
votes
1 answer

Android toggleButton.setOnText and .invalidate doesn't refresh text

I have a method like this: ToggleButton toggle = ((ToggleButton)findViewById(R.id.toggle)); toggle.setTextOn("blah"); toggle.setTextOff("blahblah"); toggle.invalidate(); // doesn't work? This methods gets called from onOptionsItemSelected. The…
ZirconCode
  • 805
  • 2
  • 10
  • 24
6
votes
3 answers

Can you set the background color on a toggle button without covering up the toggle?

I have a ToggleButton. I want the background to be clear, like in the default alarm app for the days of the week. The code below covers the toggle with the clear color. Is there any way to keep the toggle and change the background color without…
5
votes
1 answer

change drawable of selected MaterialButton using MaterialButtonToggleGroup

I can not able to change the background of the selected MaterialButton.
5
votes
2 answers

Android Material Button Toggle Group - Check None Selected

I am using MaterialButtonToggleGroup with single selection (only one button checked at a time). How to check if none of the buttons is checked? toggleGroup?.addOnButtonCheckedListener { group, checkedId, isChecked -> if (isChecked)…
4
votes
3 answers

How can we create customized toggle button in android

I have been trying to create a customized toggle button in native android, But I'm not able to achieve it. Here is the Image which I want to look like : can someone help me on this?
4
votes
3 answers

Why cursor always goes to beginning of EditText when click Toggle button in Android?

First of all, I apologize for my bad English Grammar. There is a toggleButton and EditText in my Simple Android Application. When I click the toggle button editText Box change into the password field and a normal text field. That is working…
1
2 3
13 14