如何设置视频全屏
你好,如何将视频设置为全屏现在我附上我的屏幕截图....
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="videothumb.videothumb"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".videothumb" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="ViewVideo" android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
<intent-filter><action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS">
</uses-permission>
</manifest>
ViewVideo.java
package videothumb.videothumb;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.SurfaceView;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.GridView;
import android.widget.MediaController;
import android.widget.VideoView;
public class ViewVideo extends Activity {
private String filename;
private VideoView Video;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main1);
Video=(VideoView)findViewById(R.id.VideoView01);
System.gc();
Intent i = getIntent();
Bundle extras = i.getExtras();
filename = extras.getString("videofilename");
Video.setVideoPath(filename);
Video.setMediaController(new MediaController(this));
Video.requestFocus();
Video.start();
}
} `
xml编码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<VideoView
android:id="@+id/VideoView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</VideoView>
</LinearLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您是否尝试过:
在包含媒体播放器代码的类中。
在你的 xml 中
我希望这会对你有所帮助。
Have you tried this:
in your class that contains mediaplayer code.
and in your xml
I hope this will help you.
无需代码即可全屏模式播放视频
在包含视频视图的 xml 上应用以下布局格式,它肯定会以全屏模式播放视频。因为它正在运行我的:)希望有帮助
No need of code to play video in full screen mode
Apply the following layout format over the xml containing the videoview it will for sure will play the video in full screen mode. as it is running mine :) Hope it helps
我的 java 文件:
public class VideoViewDemo extends Activity {
我的 xml 布局:
和我的 Menifest 文件:
my java file:
public class VideoViewDemo extends Activity {
my xml layout:
and my Menifest file:
顺便说一句,在您的清单中,在这一行 中,您忘记在“ViewVideo”之前添加一个点(.)。应该是“.ViewVideo”
By the way, in your manifest, at this line
<activity android:name="ViewVideo"
,you forgot to put a dot(.) before the "ViewVideo". It should be ".ViewVideo"