Component of Screen
Understanding the components of a ScreenThe basic unit of an Android application is an activity. An activity displays the user interface of your application, which may contain widgets like buttons, labels, text boxes, and so on. Typically, you define your UI using an XML fi le (e.g., the main.xml file located in the res/layout folder), which may look like this:
Component of Screen
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
>
android:layout_height=”wrap_content”
android:text=”@string/hello”
/>
Component of Screen
During run time, you load the XML UI in the onCreate() event handler in your Activity class, using
the setContentView() method of the Activity class:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
During compilation, each element in the XML fi le is compiled into its equivalent Android GUI class, with attributes represented by methods. The Android system then creates the UI of the activity when it is loaded.