2011-09-01 6 views
3

VideoView 배경을 이미지로 설정하는 방법이 없으므로 비디오를 재생할 때 양쪽에서 검은 색 부분 (왼쪽 &)이 배경에 설정된 이미지를 표시합니다. 시도했지만 비디오를 볼 수 없으며, 배경 이미지 만 표시됩니다. 비디오는 재생되지만 사운드는들을 수 있습니다.Android에서 이미지로 VideoView 배경을 설정하는 방법은 무엇입니까?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns: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> 

답변

0

당신이 비디오 프레임 크기로 비디오보기의 크기를 적용 할 수 있습니다

여기 내 XML이다. 그래서 당신은 왼쪽과 오른쪽에 검은 줄무늬가 없습니다.

배경 이미지를 설정하면 레이어 모델의 맨 위에 비디오보기를 설정해야합니다. 그렇지 않으면 이미지가 비디오보기를 덮어서 비디오를 볼 수 없습니다.

편집 레이아웃 자체와는 레이아웃의 개체로 선언해야하는 비디오 뷰의 크기와하지를 설정합니다.

<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> 
+0

감사합니다 당신 : 여기

은 예입니다. 모두 친절한 응답에 대한 ... 내가 XML 코드를 추가했습니다 제발 좀 봐주세요. –

+0

작은 예제와 함께 내 게시물을 편집했습니다. videoview.layout() 메소드를 사용하여 소스 코드에서 videoview의 크기와 위치를 설정할 수도 있습니다. – Rich

관련 문제