Relative Layout in Android :

The Relative Layout provides a good deal of flexibility for your layouts, allowing you to define the position of every component inside the layout in terms of its parent and also the other Views.

In RelativeLayout you can use “above, below, left and right” to arrange the component position

android relative layout

If you using many nested LinearLayout groups, you may be able to replace them with a single RelativeLayout. In a Android RelativeLayout is a very useful utility for designing a UI of android application, because it can eliminate nested view groups and keep your layout hierarchy flat, which improves performance.

Note : This example (Project) is developed in Eclipse Version Kepler, tested on Android 4.4.2 (KitKat Version) and SDK build-tools 22.6.3

Complete Code :

Open “res/layout/activity_main.xml” file, add components and position it via “RelativeLayout“. Read below XML code, quite verbose to tell you where to display the component.

File : res/layout/activity_main.xml

 Output Android Relative Layout :

android relative layout

Download Android Relative Layout example Source code :

Leave a Reply