A (175)

(Tuis.) #1

400 CHAPTER 11: Digital Video: Streaming Video, MediaPlayer, and MediaController classes


FrameLayout container, accessed using the menu in the HelloUniverse application, and then we will
create a 3D flythrough of one of the planets in the Universe using the Terragen 3 software.
You will also learn how to optimize the digital video using Sorenson Squeeze, and finally learn
about MediaPlayer, Uri, and MediaController objects when you stream your video using Java.


The FrameLayout Class: Framing DV Content


The Android FrameLayout class is the most basic layout container class, as it provides simple
frame layout for content, usually digital video, which is why I waited until this chapter to cover this
FrameLayout class in detail!


A FrameLayout is usually utilized to contain one single UI widget that contains some sort of new
media content such as digital video. An example of a complex UI widget that would be perfect to
use in conjunction with this FrameLayout container would be the VideoView widget. The VideoView
widget (class), which we will go over in detail in a future section of this chapter, is designed to
contain an MPEG-4 (or a WebM) digital video asset.


The FrameLayout class is a public class that extends the ViewGroup superclass, which as you
know is a master “blueprint” class which is used to create Android layout container subclasses.
The FrameLayout class hierarchy, which starts with the Java language’s Object “master class,” and
progresses down from View to ViewGroup to a FrameLayout class, would be structured using the
following Java (and Android) class hierarchy:


java.lang.Object



android.view.View
android.view.ViewGroup
android.widget.FrameLayout



The FrameLayout class was designed by Android OS developers to specify the area on the display
screen which is intended to display one single item. This is why it is named using the term “frame,”
as typically a frame holds a single image. For this reason, you should design the FrameLayout UI
to hold one child UI widget. Because a FrameLayout class does not have a lot of methods defined
which allow a lot of layout positioning attributes (or parameters), it is the simplest of the Android
layout classes. This also makes this class quite memory-efficient!


If you try to use multiple child UI widgets inside of your parent FrameLayout container, you will find
that it is difficult to position multiple elements accurately in a way that is scalable across different
screen sizes, shapes, and orientations. This is due to the lack of layout position attributes, which is
also what makes the FrameLayout class so very memory-efficient.


What happens if you attempt to use a FrameLayout container to organize multiple UI elements is that
you will see a high occurrence of UI elements overlapping each other, which is not the professional
result that you will be seeking for your UI designs. This is why I taught you about the Linear, Relative,
and Grid layout container classes first!


The only way to control positioning of your child UI widgets within the parent FrameLayout UI
container is by assigning a “layout gravity” parameter to each UI widget. This is done using the
android:layout_gravity parameter inside of each UI widget’s child tag in your FrameLayout XML
user interface definition file, which we will be creating a bit later on in the chapter, after we learn all
about the FrameLayout class as well as its nested classes that provide the layout parameters.

Free download pdf