【问题标题】:Videoview doesn't appear full screen inside frame layoutVideoview 在框架布局内没有全屏显示
【发布时间】:2014-12-03 23:14:11
【问题描述】:

我的活动播放四个背靠背视频,我希望它以全屏模式播放。但它仅覆盖 3/4 或半屏。如何使其全屏?我保留了视频视图和布局“填充 _parent”在xml中仍然没有全屏显示视频...如果我删除帧布局视频仅全屏播放但我的项目需要帧布局以避免videoview中的初始黑屏。我已经帮助了这个链接Android VideoView black screen

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">

【问题讨论】:

    标签: android android-videoview android-framelayout


    【解决方案1】:

    试试这个android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-04
      • 1970-01-01
      相关资源
      最近更新 更多