Hi guys, in this tutorial I will talk about linear and ralative layouts.
You can think of layouts as the borders of a house. Just as the rooms of the house cannot be outside the borders of the house,the components that we will use within our application cannot be defined outside the layouts.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" tools:context=".MainActivity">
Linear layout allows the components to be written one by one or side by side. It decides according to the value we give to the oriantation property of the linear layout.
If we want the components to be ordered one by one, this feature is vertical,if we want to order side by side, we set it horizontally. layout_width and layout_height are common to all components. With these properties, the height and width of the component are setting. These properties can be wrap_content and match_parent as well as numeric values. The values we give must be in px. Match parent feature allows the component to cover the all screen. With wrap_content, we ensure that the component occupies as much space as the minimum footprint.
With the id values given here, we can process these components in Java code. Therefore, when defining a component, the id value must be given. Otherwise, we cannot do any operation on this component.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity">
Relative layout positions the components written in relation. Relative layout allows you to encode difficult designs with millimeter calculations where you can perform finer operations. Relative layout also has the height and width properties like linear layuot. These two layouts have many more features. I will explain them by going through examples in the following lessons.
441 views last month, 1 views today