To insert a widget into a layout, follow these steps:
- Open the activity_main.xml file in Android Studio and click on the Design tab. As you can see, by default, Android Studio adds a TextView to the layout. Select the TextView and delete it:
- Find Button in the widget list and drag it to the center of the activity screen on the right:
- Though we placed the button in the center of the screen, the button will not actually be centered when you run the app. If we want it centered, we need to set the layout properties accordingly. ...