Is there any way to set the VideoView Background with image, so that when the video is played the black portion on both side (left & right) shows the image as set on background. I have tried but the video cannot be seen, it shows only the background image, though the video is played, its sound can be heard.
Here is my XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmln开发者_C百科s:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:id="@+id/main_layout">
<LinearLayout android:layout_height="wrap_content"
android:id="@+id/linearLayout1" android:layout_width="fill_parent"
android:background="@drawable/header">
<TextView android:id="@+id/textView1" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Chapter-1"
android:textColor="#FFFFFF" android:layout_marginLeft="170dp"
android:layout_marginTop="15dp"></TextView>
</LinearLayout>
<VideoView android:id="@+id/videoView1" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_below="@+id/linearLayout1"
android:layout_centerHorizontal="true"></VideoView>
<LinearLayout android:layout_alignParentTop="@+id/videoView1"
android:layout_centerInParent="true" android:layout_height="wrap_content"
android:id="@+id/linearLayout2" android:layout_width="fill_parent"
android:gravity="right">
<TextView android:id="@+id/overTitle" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text=" text"
android:textColor="#FFFFFF"></TextView>
</LinearLayout>
<LinearLayout android:layout_alignParentTop="@+id/videoView1"
android:background="@drawable/footer"
android:layout_alignParentBottom="true" android:layout_height="wrap_content"
android:id="@+id/linearLayout2" android:layout_width="fill_parent"
android:gravity="center">
<Button android:id="@+id/menu_btn" android:layout_below="@+id/videoView1"
android:layout_width="wrap_content" android:text="Menu"
android:textColor="#FFFFFF" android:layout_height="wrap_content"
android:layout_alignLeft="@+id/videoView1" android:layout_alignRight="@+id/videoView1"
android:background="@drawable/menu"></Button>
<Button android:id="@+id/button2" android:layout_below="@+id/videoView1"
android:layout_width="wrap_content" android:text="High"
android:textColor="#FFFFFF" android:layout_height="wrap_content"
android:layout_alignLeft="@+id/videoView1" android:layout_alignRight="@+id/videoView1"
android:background="@drawable/menu"></Button>
<Button android:id="@+id/button2" android:layout_below="@+id/videoView1"
android:layout_width="wrap_content" android:text="CC"
android:textColor="#FFFFFF" android:layout_height="wrap_content"
android:layout_alignLeft="@+id/videoView1" android:layout_alignRight="@+id/videoView1"
android:background="@drawable/menu"></Button>
<Button android:id="@+id/exit_btn" android:layout_below="@+id/videoView1"
android:layout_width="wrap_content" android:text="Exit"
android:textColor="#FFFFFF" android:layout_height="wrap_content"
android:layout_alignLeft="@+id/videoView1" android:layout_alignRight="@+id/videoView1"
android:background="@drawable/menu"></Button>
</LinearLayout>
</RelativeLayout>
you can adapt the size of your video view to the video frame size. so you don't have the black stripes on the left and right side.
if you set a background image you have to set the video view on the top of the layer model. otherwise the image covers your video view and you cannot see the video.
EDIT
to set the size of the video view you have to declare it as an object in your layout and not as layout itself.
here is an example:
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" ...>
<VideoView android:id="@+id/VideoView" android:layout_width="50dp" android:layout_height="50dp" ...(here you can set further setting of the video view)></VideoView>
<Button android:text= ...></Button>
<Button android:text=...></Button>
</LinearLayout>
精彩评论