Android UI Layout – Views & View Groups
Android’s layout is majorly made of Views which occupy the rectangular region of the UI Layout. Every region that occupies the UI is a object of View which is created from the View class. There are lots of Views that I will be covering over the next posts. We will majorly see how the View and View Groups occupy the UI Layout.
Think of these as blocks that construct the User Interface. Every rectangular block that is visible to your eyes is created with a View. 12 Views are widely used in Android currently.
Think of these as the invisible components that holds Views and ViewGroups alike. However, note that, View is the base class of ViewGroup. The ViewGroup, however is the base Class for Layouts (Confusing! Check the image below).
The following are the Views & ViewGroups mostly used in Android.
Mostly Used Views
TextView – To hold Texts (Label Holder – User cannot edit the text)
EditText – The user can modify or enter text
Button – A simple View to trigger some action
ImageView – View to hold images
ImageButton – Used to display a button with image.
CheckBox – A simple two state button which can be either checked or unchecked. Think of these as a View to toggle Values.
RadioButton – To perform Multiple selection for a particular event
RadioGroup – RadioGroup is used to group RadioButtons together. This is because RadioButtons are mutually exclusive.
ListView – This is primarily to print List of action items.
CardView – Very powerful material design update that creates individual cards in the Android UI.
Spinner – Not the circle spinning that you have seen. These are more like drop down list which holds arrays of values for you to choose from.
AutoCompleteTextView – Like the name suggests, it provides autocomplete feature from the list of values you feed to it.
Mostly Used ViewGroups
View groups are base class for layouts (Think of these as invisible layers covering your views). Widely used Views are
LinearLayout – Basic, simple linear arrangement of Views inside it (Vertical or Horizontal)
RelativeLayout – Relative arrangement of the views (Specifying what is below what)
ConstraintLayout (Recent Material Design Update) – This is a very powerful Layout which allows you to resize the views inside it.
FrameLayout – Blocks out an area to hold a single view inside it (Advisable to use only one child view inside it)
RecyclerView – Think of these as a simple way to repeat a view (Dynamic loading of a user names can use Recycler View with TextView inside it)
ScrollView – You guessed it right. Anything inside this ViewGroup can be scrolled independently
CoordinatorLayout (Recent Update) – Think of these as a Update to hold multiple Views inside a FrameLayout. This is very useful for moving your elements with the CoordinatorLayout with just the XML only.
Usage of the View and ViewGroups
It is primary to know how each and every View and ViewGroups work. The beginner can check out my post here, to find all the useful materials to create a proper layout design.
Most widely used Views are TextView, Button, EditText, ImageView.
ViewGroups to hold these Views – LinearLayout, RecycleView, FrameLayout.
I will be explaining all the necessary Views and ViewGroups One by One from my next posts.
Read my post here, which consists of list of all the materials to create a proper and professional Looking UI for your Android Application if you are already familiar with all the Views and ViewGroups.
“Learn and be Curious”.