CHAPTER 11: Digital Video: Streaming Video, MediaPlayer, and MediaController classes 401
This layout_gravity design parameter does not allow developers to do any of the pixel-precise
positioning that is possible using the other more advanced (and less memory-efficient) layout
container classes. The FrameLayout class essentially allows Android OS to do all of your UI design
positioning so that you can scale your UI design to fit all of the different Android device screen
sizes and orientations, usually in a full-screen mode, which is the optimal mode for use with digital
video assets. This gravity parameter for a FrameLayout class is provided by a nested class called
FrameLayout.LayoutParams. We’ll be covering this nested class in the next section of this chapter.
It is identical to the gravity parameter that was used in the other layout container classes (ViewGroup
subclasses) that we covered in Chapters 6, 7, and 8. I’m going to cover layout gravity again here,
to reinforce your comfort with it, because it’s very important to UI design.
Since it is a basic UI layout class, you can also utilize the FrameLayout class as a superclass, for
the purpose of creating more specialized UI-related classes. Any classes which you create by
subclassing a FrameLayout class would be termed direct subclasses of the FrameLayout class.
Some of the “known” direct subclasses of FrameLayout (that is, the FrameLayout subclasses which
have already been coded for you, and which have been made permanent classes in the Android
API) will include: DatePicker, TabHost, MediaController, CalendarView, ScrollView, TimePicker,
ViewAnimator, HorizontalScrollView, GestureOverlayView, and AppWidgetHostView classes. The
FrameLayout class also has several known indirect subclasses which are part of the Android API.
These include: TextSwitcher, ViewFlipper, ImageSwitcher, FragmentTabHost, and the ViewSwitcher
class. Next, let’s take a look at the FrameLayout.LayoutParams class.
FrameLayout.LayoutParams Nested Class: Gravity
The FrameLayout.LayoutParams class is a nested class which subclasses the ViewGroup.
MarginLayoutParams nested class, which, in turn, subclasses (or extends) the ViewGroup.
LayoutParams nested class that was coded originally using the Java Object master class in order to
create layout parameters for all ViewGroup subclasses.
Android layout parameter, or LayoutParams, nested classes are what provide the layout parameters
for your UI designs, which are usually created via XML, as you’ll see a bit later on in this chapter
when you create the FrameLayout containing your VideoView UI widget.
The FrameLayout.LayoutParams class hierarchy starts out with a Java Object and progresses
down the class hierarchy from ViewGroup.LayoutParams to ViewGroup.MarginLayoutParams to
FrameLayout.MarginLayoutParams, and thus would be structured like the following:
java.lang.Object
android.view.ViewGroup.LayoutParams
android.view.ViewGroup.MarginLayoutParams
android.widget.FrameLayout.LayoutParams
FrameLayout.LayoutParams inherits all ViewGroup.LayoutParams as well as ViewGroup.
MarginLayoutParams (margin parameters), and then the class adds the layout_gravity parameter
and its constants, which we are going to cover in detail in this section, since these constants are
specifically intended to be used with the FrameLayout UI container which we’re going to be using for
the digital video playback engine we are creating in this chapter.