Published on

Android View System: Basic Knowledge

Authors

The Android View System is the system that represents the interface in Android applications through XML file structures to build the UI. Architecturally, this system has a Tree structure, where the parent Node is the Layout, and the child Nodes can be Layouts or Views. This lesson provides detailed instructions on the features and proper usage of various Layouts and Views in Android.

Android Layout

FrameLayout

Is the simplest ViewGroup in Android. Because FrameLayout is the simplest, it also has the best performance. However, the disadvantage of FrameLayout is that it is difficult to arrange the position of child Elements within it. Therefore, in Android programming, we rarely use FrameLayout directly, or if we do, we use it through CardView.

CardView

CardView is a class that inherits from FrameLayout. However, CardView has some additional features that make interfaces drawn by CardView more modern, beautiful, and attractive.

CardView provides APIs to set up a View in the shape of a Card, customize rounded corners, shadows, and colors. And you can easily customize the child Elements inside the CardView.

We will go through the details of using CardView effectively in the practical exercises of the Android programming course.

LinearLayout

LinearLayout is another type of ViewGroup in Android. In LinearLayout, child Elements are arranged adjacent to each other horizontally or vertically (this variable is set up in LinearLayout)

LinearLayout is very easy to use and convenient in UI construction. In the following lessons, I will guide you to use these ViewGroups proficiently to have a beautiful and user-friendly application that can attract users.

ConstraintLayout

ConstraintLayout is a special type of ViewGroup. ConstraintLayout was created to replace RelativeLayout. Nowadays, in new applications, people have removed all RelativeLayout in the main interface of the application and switched to using ConstraintLayout. The reason for this replacement is because of the optimization of ConstraintLayout, which is clearly shown in how this type of ViewGroup calculates the position based on the constraints between its Child Elements.

ConstraintLayout supports a wide range of constraints so that you can build a UI suitable for each specific case. However, there are many constraints. To use ConstraintLayout proficiently, we need a lot of practice and encounter enough cases to improvise.

In this Android programming course, Danh will work with you to build the interface of applications entirely using ConstraintLayout, LinearLayout, and CardView.

Android View

TextView, Button

In essence, TextView and Button are two similar views. Both are Views that can display Text, and receive onClick events and customize colors and sizes.

In addition, once you are proficient with the Android View System, you can completely build your own TextView and Button.

 eventHandler.onClickExecUsingThread()}"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

TextInputLayout

TextInputLayout is a type of View specifically used to receive input from the user's keyboard. The input can be Text, Number, Password, etc. Please see the example to understand more clearly.

In practice, you will need to listen for events that change the value of TextInputLayout in Android code for the purposes of the application. Details will be presented in the examples and course projects.

ImageView

This is a very simple View, used to display an image on the screen.

To load images into ImageView in Android, you can use Android image loading libraries such as Glide, Coil, or build your own image loading mechanism... or set it directly through drawable in Android Resource.