412 CHAPTER 11: Digital Video: Streaming Video, MediaPlayer, and MediaController classes
Creating a VideoView Widget in the FrameLayout
Let’s get started:
- Click the activity_play.xml tab to edit your XML UI definition, shown in
Figure 1 1- 8 , and add a line of space after the openingtag.
Use a left-facing chevron to open the pop-up widget helper dialog. Find
thewidget and double-click on it to insert it inside of the container.
Figure 11-8. Add a child
- Add an android:id parameter with a value of @+id/videoPlayer, and a
required layout_width and layout_height parameter, set to the match_parent
constant, so that the VideoView is scaled to fit inside of the FrameLayout.
Notice the
fit the screen as well, because both of these UI elements are set to match_parent and the top-most
parent is the display screen.
- The next thing that we need to do to prepare this VideoView UI widget for
use is to declare it in your PlayVideo Activity subclass, at the top of the code
base, on top of (before) the onCreate( ) method, as seen in Figure 11-9.