How to Add a CheckBox to an Activity, using XML

CheckBox was added in API Level 1

1. Create an Android project, if you don't already have one.

2. Open the main.xml file and add the below code to add a CheckBox to the XML file between the Layout tags.

<CheckBox   
    android:layout_width=”wrap_content”
    android:layout_height=”wrap_content”
     />

3. Compile and run!

Next Recommended Article: android:id - How to Name a CheckBox