如何在框架布局内制作视频全屏

时间:2014-10-08 16:52:23

标签: android android-videoview

我的活动播放四个背靠背视频,我希望它以全屏模式播放。但它只覆盖3/4或半屏。如何使其全屏?我保持视频和布局“填写 _parent“在xml中仍然没有全屏显示视频......

XML     

    <FrameLayout
        android:id="@+id/frameLayout1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"

         >

    <VideoView
    android:id="@+id/intro_video_loop_view"
    android:layout_width="fill_parent"
    android:layout_alignParentRight="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_alignParentBottom="true"
    android:layout_height="fill_parent"



    />

        <FrameLayout
            android:id="@+id/placeholder"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:background="@color/white">
        </FrameLayout>
    </FrameLayout>



    <ImageView
        android:id="@+id/signInWithFacebook"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:adjustViewBounds="true"
        android:background="@null"
        android:src="@drawable/fb_login_selector"
        android:visibility="visible"
        android:layout_above="@+id/signInWithGooglePlus"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

    <ImageView
        android:id="@+id/signInWithGooglePlus"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:background="@null"
        android:src="@drawable/gp_login_selector"
        android:layout_above="@+id/muteAudio"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_marginBottom="5dp" />

    <ImageButton
        android:id="@+id/muteAudio"
        android:layout_width="36dp"
        android:layout_height="36dp"
        android:layout_margin="5dp"
        android:adjustViewBounds="true"
        android:scaleType="fitXY"
        android:background="@null"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        android:src="@drawable/unmute_audio"
        android:visibility="visible"/>

    <ImageView
        android:id="@+id/video_message_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:src="@drawable/guggu_text"
        android:gravity="center_horizontal"

        />

    <ProgressBar
        style="?android:attr/progressBarStyleLargeInverse"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/progressBarGooglePlus"
        android:visibility="invisible"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />

</RelativeLayout>

   public void playVideo() {
final int a[]={R.raw.intro_video_full,R.raw.two,R.raw.newv,R.raw.four};
        final VideoView lIntroVideo = (VideoView) findViewById(R.id.intro_video_loop_view);


      lIntroVideo.setVideoPath("android.resource://" + getPackageName() + "/" + R.raw.intro_video_full);

        lIntroVideo.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer aMediaPlayer) {
                View placeholder = (View) findViewById(R.id.placeholder);

                placeholder.setVisibility(View.GONE);
                lIntroVideo.start();
                lIntroVideo.requestFocus();

               try {


                    if (isAudioMuted) {
                        aMediaPlayer.setVolume(0f, 0f);
                    } else {
                        aMediaPlayer.setVolume(0f, 0.5f);
                    }


                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });




        lIntroVideo.setOnCompletionListener(new MediaPlayer.OnCompletionListener()
        {
            @Override
            public void onCompletion(MediaPlayer mp)
            {  if(i%4==0)
            {
                lIntroVideo.setVideoPath("android.resource://" + getPackageName() + "/" + a[2]);
                i++;}
                else  if(i%4==1)
            {
                lIntroVideo.setVideoPath("android.resource://" + getPackageName() + "/" + a[3]);
                i++;}
            else  if(i%4==2)
            {
                lIntroVideo.setVideoPath("android.resource://" + getPackageName() + "/" + a[1]);
                i++;}
            else  if(i%4==3)
            {
                lIntroVideo.setVideoPath("android.resource://" + getPackageName() + "/" + a[0]);
                i++;}

                lIntroVideo.start();

            }
        });

    }

清单

<activity android:name=".IntroVideoActivity_"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
            android:configChanges="orientation|screenSize">

0 个答案:

没有答案