Learn how to build layouts.

60
BUILDING LAYOUTS

Transcript of Learn how to build layouts.

Page 1: Learn how to build layouts.

BUILDING LAYOUTS

Page 2: Learn how to build 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

Page 3: Learn how to build layouts.
Page 4: Learn how to build layouts.
Page 5: Learn how to build layouts.
Page 6: Learn how to build layouts.

TYPES OF VIEW GROUPS

Linear Layout Relative Layout

Page 7: Learn how to build layouts.

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.

Page 8: Learn how to build layouts.

LINEAR LAYOUT

It can also arrange its children in a horizontal row

Page 9: Learn how to build layouts.

RELATIVE LAYOUT

Also has its own rules on how to position its children within it. For Example

Relative to the parent Relative to t

Page 10: Learn how to build layouts.

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

Page 11: Learn how to build layouts.

RELATIVE LAYOUT

Relative to other views

Page 12: Learn how to build layouts.
Page 13: Learn how to build layouts.
Page 14: Learn how to build layouts.

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>

Page 15: Learn how to build layouts.

WIDTH AND HEIGHT

Fixed width and height Wrap content Match parent

Page 16: Learn how to build layouts.
Page 17: Learn how to build layouts.
Page 18: Learn how to build layouts.

EVENLY SPACING OUT VIEWS

Page 19: Learn how to build layouts.
Page 20: Learn how to build layouts.

LAYOUT WEIGHT

Can be used to evenly distribute views. The higher the weight, the more space the view takes

Page 21: Learn how to build layouts.
Page 22: Learn how to build layouts.

EXAMPLES

Page 23: Learn how to build layouts.
Page 24: Learn how to build layouts.
Page 25: Learn how to build layouts.
Page 26: Learn how to build layouts.
Page 27: Learn how to build layouts.
Page 28: Learn how to build layouts.
Page 29: Learn how to build layouts.
Page 30: Learn how to build layouts.
Page 31: Learn how to build layouts.
Page 32: Learn how to build layouts.
Page 33: Learn how to build layouts.
Page 34: Learn how to build layouts.

RELATIVE LAYOUT

This will help you build even more flexible layouts

Page 35: Learn how to build layouts.
Page 36: Learn how to build layouts.
Page 37: Learn how to build layouts.
Page 38: Learn how to build layouts.
Page 39: Learn how to build layouts.
Page 40: Learn how to build layouts.
Page 41: Learn how to build layouts.
Page 42: Learn how to build layouts.
Page 43: Learn how to build layouts.
Page 44: Learn how to build layouts.
Page 45: Learn how to build 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

Page 46: Learn how to build layouts.
Page 47: Learn how to build layouts.
Page 48: Learn how to build layouts.
Page 49: Learn how to build layouts.
Page 50: Learn how to build layouts.
Page 51: Learn how to build layouts.

PADDING VS MARGIN

Page 52: Learn how to build layouts.
Page 53: Learn how to build layouts.
Page 54: Learn how to build layouts.
Page 55: Learn how to build layouts.

QUIZ

Page 56: Learn how to build layouts.
Page 57: Learn how to build layouts.
Page 58: Learn how to build layouts.
Page 59: Learn how to build layouts.
Page 60: Learn how to build layouts.