Junior — Middle
Can you give examples of different types of interface layouts you've encountered?
sobes.tech AI
Answer from AI
In Android, there are several main types of layouts used to organize interface elements:
- LinearLayout — arranges child elements in a single row vertically or horizontally.
- RelativeLayout — allows positioning elements relative to each other or the parent.
- ConstraintLayout — a more flexible and powerful layout that enables creating complex interfaces using constraints between elements.
- FrameLayout — a simple container that overlays child elements on top of each other.
- GridLayout — arranges elements in a grid with a specified number of rows and columns.
For example, to create a vertical list of buttons, you can use a LinearLayout with vertical orientation:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button 1" />
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button 2" />
</LinearLayout>