Friday, June 24, 2011

Example of FrameLayout

It's a example of using FrameLayout, to make two view (a SeekBar and a SurfaceView here) overlap.

Example of FrameLayout

It use the old post "Implement a SeekBar to control the volume of Video Player" as a example. The Java code keep no change, modify the layout file, main.xml, to move the Volumn Control (SeekBar) over the top of the video(SurfaceView).

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"/>
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<Button
android:id="@+id/playvideoplayer"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="- PLAY Video -"
/>
<Button
android:id="@+id/pausevideoplayer"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="- PAUSE Video -"/>
</LinearLayout>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<SurfaceView
android:id="@+id/surfaceview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<SeekBar
android:id="@+id/volbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10px"/>
</FrameLayout>
</LinearLayout>


2 comments:

3z0ru$ said...

Thanks a lot! You made a new blog entry to answer my question; I really appreciate your time and effort.

Unknown said...

thanks very much.