Welcome to Part 4 of this review of the Pluralsight course Android Layout Fundamentals by Chiu-Ki Chan.
Chiu-Ki is a mobile developer with a passion in speaking and teaching.
Android Layout Fundamentals is the 5th course in the Android Learning Path.
Also in this series:
Chiu-Ki says this is a simple layout which allows us to put views on top of each other.
It’s not obvious what the hex codes #9cf and #c9f mean here.
But we can improve readability by using resources:
We put this in a file called res/values/colors.xml and Chiu-Ki says this is the same kind of idea as strings.xml
We can use color values “@color/blue” and “@color/purple”.
The FrameLayout doesn’t render anything on it’s own.
The first view outputs a blue background.
The second view is drawn on top of the first view and is purple.
Chiu-Ki says we can also use gravity to move the views around, and we see that we can use multiple values for gravity, with each value separated with a | (the pipe character).
Next we see the effect of margins applied to views within a FrameLayout.
FrameLayout can be used like a picture frame, and we see how to show a tiger frame around a cat picture.
There’s also a foreground parameter:
With this we don’t need two image views as children. All we need is a FrameLayout with a single ImageView in it.
We also can create non-frame foregrounds. There’s a parameter call forgroundGravity which alters the default fill screen functionality to the placement we want. This displays a ribbon in the top left hand corner:
Chiu-Ki summarizes all of these points at the end of this lesson.