Description
Course info
Rating
(519)
Level
Intermediate
Updated
Jan 13, 2014
Duration
1h 39m
Description

Android has four basic layout classes: LinearLayout, RelativeLayout, FrameLayout and TableLayout. How do they work? How to decide when to use which? This course goes into the details of each class, explains their various attributes, then demonstrates various tools and techniques to examine and optimize your layouts.

About the author
About the author

Chiu-Ki is a mobile developer with a passion in speaking and teaching. Her mother tongue for mobile is Android, acquired while working on Android Maps at Google. Now she runs her own mobile development company to produce delightful apps, and speaks at various conferences to share her knowledge.

More from the author
Android Fundamentals: Intents
Beginner
1h 38m
Jun 12, 2017
Start Developing for Android
Beginner
1h 3m
Dec 9, 2015
Android Custom Components
Intermediate
1h 39m
Jan 29, 2015
Section Introduction Transcripts
Section Introduction Transcripts

Introduction
This is Chiu-Ki Chan, and welcome to Android Layout Fundamentals, the Introduction module. In this module, I'm going to tell you what is layout, describe a few basic layouts, and also some basic attributes that you can use to configure your layouts. First things first. What is a layout? A layout defines the visual structure for user interface. It organizes the screen elements into a viewer hierarchy and puts each of them to a specific location. Imagine you need to put two buttons on this screen. How will you desire where to put it? The layout system allows you to declaratively define where you want the elements to be, and then Android will compute the XY coordinates for each element for you. So, for example, you may want to line them up side-by- side horizontally like this, or you want to line them up, but then you want them to be vertically stacked like this. Or maybe you just want to put them on each side of the screen smack in the middle. In each case, we are telling Android declaratively where we want these elements and allowing Android to take care of the screen size, the screen density, and various factors to compute the exact position for us. This is what we mean when we say that the layout defines the visual structure of the user interface. We give rules to the system of where we want the visual elements, and then the system will place them accordingly.

LinearLayout
This is Chiu-Ki Chan, and welcome to Android Layout Fundamentals, the LinearLayout module. In this module, I will describe to you what is LinearLayout and show you some of its attributes. I will explain how layout_gravity interacts with LinearLayout and show you how to use weight to achieve proportional layouts. Finally, I will show you how to nest LinearLayouts to make a more complicated UI. What is LinearLayout? LinearLayout aligns its children in a single direction. The two directions are horizontal and vertical. A horizontal LinearLayout is one row high, and its elements are stacked one against each other horizontally. A vertical LinearLayout have as many rows as there have children, and they are stacked vertically. LinearLayout is one of the most commonly used layouts in Android. It lets you put views on the screen one after another. You can also use it to divide a width or a height by ratio as a strategy to handle devices with different screen dimensions.