Post on 21-Jan-2017
BUILDING LAYOUTS
VIEW GROUPS
View Groups are a collection of views. (Container for views)
There can only be one root view. So if we have more than one view, we need to put them in a view group
TYPES OF VIEW GROUPS
Linear Layout Relative Layout
LINEAR LAYOUT
It can arrange its children in a vertical column Notice that we are not limited to just one textview and one
imageview. We can have as many as we want.
LINEAR LAYOUT
It can also arrange its children in a horizontal row
RELATIVE LAYOUT
Also has its own rules on how to position its children within it. For Example
Relative to the parent Relative to t
RELATIVE LAYOUT
Relative to parent A child imageview aligned to the top of the parent A child textview aligned to the bottom of the parent
RELATIVE LAYOUT
Relative to other views
LINEAR LAYOUT
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_height="wrap_content" android:layout_width="wrap_content">
</LinearLayout>
WIDTH AND HEIGHT
Fixed width and height Wrap content Match parent
EVENLY SPACING OUT VIEWS
LAYOUT WEIGHT
Can be used to evenly distribute views. The higher the weight, the more space the view takes
EXAMPLES
RELATIVE LAYOUT
This will help you build even more flexible layouts
RELATIVE TO OTHER VIEWS
When positioning views relative to other views, you can constraints eg;
One view must be above the other Or one imageView must be to the left of another
PADDING VS MARGIN
QUIZ