‫In the previous video, we learned about the linear layout that position the views in a row or a column.
‫In this video, we'll learn about the relative layout to create a relative layout.
‫We start with relative layout tag, and the ending tag should be relative layout.
‫So the root member or the root element of the of this file is a relative layout.
‫Relative layout is a versatile view group that arranges its child views, widgets or other layout elements
‫relative to one another or to the parent container.
‫It allows you to create complex and flexible user interfaces by specifying the positioning of child
‫abuse in relation to each other.
‫For example, if I have two text views, you can see they are overlapped here because I didn't specify
‫the position of number one relative to number two or vice versa.
‫So inside the relative layout I can specify child views, widgets and use various attributes to position
‫them relative to each other or to the parent container.
‫For example, I'll give text view number one, an ID, text number one, and text number two, I'll
‫give it an ID, text number two position text number two under text number one, I can use layout below
‫or above or margin.
‫These are the above and below.
‫These are parameters and attributes that are specific for the relative layout.
‫So for example, I need to specify this text view and position it below.
‫Text number one, I specify the ID text number one and you can see that text number two is positioned
‫under the text number one.
‫Also, I can center horizontally with the relative layout using the layout center horizontal equal to
‫true.
‫You can see that it is centered horizontally according to the parent which is here the relative layout.
‫Okay.
‫You can use other various attributes to control the positioning of child views such as align, top,
‫align left, align button or align right.
‫So for example, if I need number two to align starting from the start of text number one, I can use
‫align left ID, and here I specify text number one.
‫You can see that the starting of the text number two is aligned to the starting of the number one.
‫By using align left, I can use align right so that the alignment should take place here to the right.
‫So for example, if I add 200 text number 200, you can see the text is getting enlarged in this direction
‫because the alignment is taking place to the right.
‫You can also use margins and padding to create spacing between child views and parent container.
‫For example, padding 20 DPI.
‫You can see this is the padding and I'll create margin 20 DPI.
‫You can see this is the margin 20 DPI from above, 20 DPI from the right align.
‫You can see this virtual line.
‫Remember, the relative layout offers a lot of flexibility.
‫Complex layout can sometimes become difficult to manage.
‫In such cases you might want to consider using other layout managers like constraint layout for more
‫advanced and maintainable UI designs.