如何让VideoView在lanscape中全屏显示?
我在活动的清单文件中设置了以下内容。
机器人:screenOrientation = “风景” 机器人:主题= “@机器人:风格/ Theme.NoTitleBar.Fullscreen” >
还有什么我需要做的吗?
答案 0 :(得分:4)
<?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" >
<VideoView android:id="@+id/myvideoview"
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">
</VideoView>
</RelativeLayout>
需要对齐
答案 1 :(得分:2)
使用VideoView
和android:layout_width
设置android:layout_height
以填充屏幕。
请注意,在大多数情况下,实际视频不会填满屏幕,因为视频的宽高比与屏幕的宽高比不匹配。
答案 2 :(得分:0)
通过更改布局配置,您可以拉伸视频。
<?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">
<VideoView android:id="@+id/videoViewRelative"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</VideoView>
</RelativeLayout>
要使活动全屏,您可以按如下方式更改主题
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
或者您可以通过在setContentView()
中onCreate()
方法之前的活动(java)类中添加以下代码来实现此目的。
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);