2011-10-21 2 views
3

저는 응용 프로그램에서 작업 중이며 비디오 위에 이미지가 고르게 쌓여 있습니다. 첨부 된 사진에서 확인할 수 있습니다. 왜 비디오 플레이어가 사진처럼 장치의 바닥을 기본으로 제어합니까? 가능하다면 비디오 위로 그냥 이동하고 싶습니다. 이 화면에 대한 나의 레이아웃입니다 : 나는 비디오의 상단에있는 비디오 컨트롤을 이동할 수 있습니다 경우비디오 컨트롤이 장치의 맨 아래에 기본 설정됩니다.

<?xml version="1.0" encoding="UTF-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/mobile_vforum_bg" 
    > 
    <VideoView 
     android:id="@+id/vidPlayer" 
     android:layout_width="320dip" 
     android:layout_height="240dip"> 
    </VideoView> 
    <WebView 
     android:id="@+id/slideHolder" 
     android:layout_width="320dip" 
     android:layout_height="240dip" 
     android:layout_gravity="bottom"> 
    </WebView> 
    <ListView 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:id="@+id/slideList" 
     android:background="#000000"> 
    </ListView> 
</FrameLayout> 

Uploaded Image of phone

아는 사람?

+0

"VideoView"에 대한 문서에 따르면 ... "모든 레이아웃 관리자에서 사용할 수 있도록 비디오에서 측정 값을 계산합니다." 'dip's에서 너비/높이를 설정하는 대신'wrap_content'를 사용하여 간단하게 시도해 보셨습니까? – Squonk

+0

나는 VideoView 너비/높이를 내용을 줄 바꿈으로 설정하려고 시도했지만 동일한 동작을합니다. 인터넷 검색의 길일이 될 것입니다. – Ronnie

답변

0

아마도 FrameLayout을 사용하고 있으며 모든 것을 표시하기에 충분한 공간이 디스플레이와 관련이 있습니다. 크기에 정확한 픽셀 사양을 사용해야하는 이유가 있습니까? 안드로이드에서는 앱의 크기가 어느 정도인지 알지 못하기 때문에 항상 가능한 한 피하는 것이 좋습니다.

+0

잘 320x240은 내 동영상 크기입니다. 내 다른 옵션은 무엇입니까? – Ronnie

+0

그건 이해할 수 있습니다. 당신은 다른 레이아웃 중 하나를 사용하여 시도 해 봤나? –

+0

LinearLayout을 시도했으며 같은 방식으로 동작합니다. – Ronnie

3

컨트롤에 대한 앵커보기를 설정하고 앵커보기가 전체 화면을 차지하지 않도록해야합니다. 예를 들어, 다음 샘플 레이아웃의 (불완전,하지만 가로 질러 점을 얻는다) :

mPreview = (VideoView) findViewById(R.id.preview_video_view); 
    MediaController mediaController = new MediaController(this); 
    mediaController.setAnchorView(mPreview); 

:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    > 

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/preview_video_container_layout" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     > 
     <VideoView 
      android:id="@+id/preview_video_view" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
     /> 
    </LinearLayout> 
</LinearLayout> 

그런 다음 코드에서 당신은 미디어 컨트롤러를 설정할 때 다음을 수행 할 것 핵심은 내부 선형 레이아웃이 전체 화면을 차지하지 않도록 높이에 대한 내용을 포함한다는 것입니다. 그러면 비디오 바로 아래에 컨트롤이 표시됩니다. 비디오 자체 위에 컨트롤을 가지고있는 것처럼 (그리고 나서 나타나거나 사라지는 것처럼) 더 펑키 한 무언가를하고 싶다면 비디오 컨트롤로 컨트롤을 만들고 비디오보기로 레이아웃해야합니다.

관련 문제