Questions tagged [android-switch]

Switch is an android class for a two state toggle switch

From Android Developer Documentation:

A Switch is a two-state toggle switch widget that can select between two options. The user may drag the "thumb" back and forth to choose the selected option, or simply tap to toggle as if it were a checkbox. The text property controls the text displayed in the label for the switch, whereas the off and on text controls the text on the thumb. Similarly, the textAppearance and the related setTypeface() methods control the typeface and style of label text, whereas the switchTextAppearance and the related seSwitchTypeface() methods control that of the thumb.

The Android Developer Guide regarding toggle buttons also states, that

The ToggleButton and Switch controls are subclasses of CompoundButton and function in the same manner, so you can implement their behavior the same way.

201 questions
0
votes
1 answer

How to set activeColor to SwitchThemeData in Flutter

activeColor property is available inside Switch but not available in SwitchThemeData. How can we get the same effect as activeColor in SwitchThemeData as a global property for Switch
kartik
  • 93
  • 9
0
votes
1 answer

How to create a slide switch using jetpack compose?

I want to create this type of slid switch using jetpack compose but I don't know how to do it can anyone help me with it? it will toggle between this 2 option
0
votes
1 answer

SwitchCompat doesn't display well in dark mode

I have a custom SwitchCompat that renders fine in the app's daytime theme, but when the dark theme is enabled, SwitchCompat looks too light. Here is a photo: SwitchCompat:
0
votes
0 answers

How to add a Switch to a PopupMenu programmatically ( Without using XML )?

I want to add a Switch to a PopupMenu as an item, I also don't want to use any XML codes, Is there is any way to do this? here is an example of my code : options.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View…
Omar Hemaia
  • 188
  • 10
0
votes
1 answer

Switch color is not respected/damped - turn off effect on trackTint color (OnColor)

Normally you would use the OnColor like this to customize the track color and you get the following result: IsToggled = true; IsToggled =…
testing
  • 19,681
  • 50
  • 236
  • 417
0
votes
1 answer

Alignment vertical the switch on Android

I am trying to create a layout (Android Studio) in which I need to vertically align various controls like Switch in below screenshot.
0
votes
1 answer

Display notification at a specific time

I have currently created a notification which displays no problem when the switch is checked, however I want to create an if statement to set a current time of when the notification will be displayed. I have tried the below however the notification…
0
votes
1 answer

Set notification for specific time

I have currently created a notification which displays no problem when the switch is checked, however I want to create an if statement to set a current time of when the notification will be displayed. I have tried the below however the notification…
0
votes
1 answer

SwitchCompat text not showing up on action bar

I have an action bar on my app and inside the action bar there is a SwitchCompat widget. I've gotten the widget to show up on the action bar but there is no text beside the switch when I test the app. Here's my menu.xml file
0
votes
4 answers

How to reduce material.switchmaterial.SwitchMaterial end margin in android?

I've used "com.google.android.material.switchmaterial.SwitchMaterial" in that left margin having some space. How to reduce that? I've need align straight of the everyone text. I'm not add end margin or padding of the switch, Parent layout margin…
0
votes
1 answer

How do you not toggle Switch when hitting enter twice on a keyboard in Android Studio

When pressing enter twice on the editText "textbox" the first push will submit the button as usual, but the second press will toggle the switch. How do I ensure that the switch does not get toggled? …
0
votes
1 answer

Changing the background color of a Switch

I've tried using android:background="@color/colorWhite"/> but it changes the entire background of the switch not that small grey part.
DIRTY DAVE
  • 2,523
  • 2
  • 20
  • 83
0
votes
0 answers

Switch state using intent

Hello everyone from more a week I am facing a problem that when I change the switch in activity 1 then when I switch to another activity then i.e: activity 2 using intent the switch compact state which we had changed in activity 1 is reflecting…
0
votes
1 answer

Android ListView with Switch buttons - only one switch active at a time

I have a list view with two switches. I want the functionality to work were only one switch may be active at a time. --UPDATED My Adapter: public class NotificationsAdapter extends ArrayAdapter { private Context context; private String…
AndroidDev123
  • 280
  • 3
  • 24
0
votes
2 answers

how do i remove the switch on my home screen?

So currently my home screen is as of such ![enter image description here][1] however though in my navigation drawer I have already a switch created inside. Hence as such, I would like to ask if there is any way to ensure that the only switch that I…
user13307946