Radio button

A radio button allows a traveller to select a single value from a small set of options.

RadioButton

Maven Central Class reference Source code

Default

Day Night
RadioButton component RadioButton component - dark mode

Installation

Backpack Android is available through Maven Central. Check the main Readme for a complete installation guide.

Usage

The RadioButton component can be used in both XML and Kotlin/Java

Example of a RadioButton in XML


                                                
                                                <RadioGroup
                                                android:layout_width="wrap_content"
                                                android:layout_height="wrap_content"
                                                android:checkedButton="@+id/radio_button_checked">
                                                
                                                <net.skyscanner.backpack.radiobutton.BpkRadioButton
                                                  android:layout_width="wrap_content"
                                                  android:layout_height="wrap_content"
                                                  android:text="Unchecked" />
                                                
                                                <net.skyscanner.backpack.radiobutton.BpkRadioButton
                                                  android:id="@+id/radio_button_checked"
                                                  android:layout_width="wrap_content"
                                                  android:layout_height="wrap_content"
                                                  android:text="Checked" />
                                                
                                                </RadioGroup>

Example of a RadioButton in Kotlin


                                                
                                                import net.skyscanner.backpack.radiobutton.BpkRadioButton
                                                
                                                val radioButton = BpkRadioButton(context).apply {
                                                  isChecked = true
                                                }
                                                radioGroup.addView(radioButton)

Theme Props

  • radioButtonColorChecked
  • radioButtonColorDisabled
  • radioButtonColor

Styles can be changed globally through bpkRadioButtonStyle. Check theming for more information.