Android UI Layouts

The basic building block for user interface is a View object which is created from the View class and occupies a rectangular area on the screen and is responsible for drawing and event handling. View is the base class for widgets, which are used to create interactive UI components like buttons, text fields, etc.

The ViewGroup is a subclass of View and provides invisible container that hold other Views or other ViewGroups and define their layout properties.

At third level we have different layouts which are subclasses of ViewGroup class and a typical layout defines the visual structure for an Android user interface and can be created either at run time using View/ViewGroup objects or you can declare your layout using simple XML file main_layout.xml which is located in the res/layout folder of your project.

This tutorial is more about creating your GUI based on layouts defined in XML file. A layout may contain any type of widgets such as buttons, labels, textboxes, and so on.

Once your layout created, you can load layout resource in your MainActivity's onCreate() methid using this line: 


setContentView(R.layout.activity_main);

There are number of layout provided by Android which you will use in your application to provide diiferent view, look and feel.

Comments

Popular posts from this blog

MVC Architecture in Android

Get Current Location using GPS/Network Provider

SQLiteDatabase (Without SqliteOpenHelper class)