Videoview 在框架布局内没有全屏显示
Posted
技术标签:
【中文标题】Videoview 在框架布局内没有全屏显示【英文标题】:Videoview doesn't appear full screen inside frame layout 【发布时间】:2014-12-03 23:14:11 【问题描述】:我的活动播放四个背靠背视频,我希望它以全屏模式播放。但它仅覆盖 3/4 或半屏。如何使其全屏?我保留了视频视图和布局“填充 _parent”在xml中仍然没有全屏显示视频...如果我删除帧布局视频仅全屏播放但我的项目需要帧布局以避免videoview中的初始黑屏。我已经帮助了这个链接android VideoView black screen
xml
<FrameLayout
android:id="@+id/frameLayout1"
android:layout_
android:layout_
>
<VideoView
android:id="@+id/intro_video_loop_view"
android:layout_
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_
/>
<FrameLayout
android:id="@+id/placeholder"
android:layout_
android:layout_ android:background="@color/white">
</FrameLayout>
</FrameLayout>
<ImageView
android:id="@+id/signInWithFacebook"
android:layout_
android:layout_
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_
android:layout_
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_
android:layout_
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_
android:layout_
android:layout_alignParentTop="true"
android:src="@drawable/guggu_text"
android:gravity="center_horizontal"
/>
<ProgressBar
style="?android:attr/progressBarStyleLargeInverse"
android:layout_
android:layout_
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">
【问题讨论】:
【参考方案1】:试试这个android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen"
【讨论】:
以上是关于Videoview 在框架布局内没有全屏显示的主要内容,如果未能解决你的问题,请参考以下文章