我正在尝试使此 VideoView 以全屏模式显示:
public class ViewVideo extends Activity {
private String filename;
private static final int INSERT_ID = Menu.FIRST;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
System.gc();
Intent i = getIntent();
Bundle extras = i.getExtras();
filename = extras.getString("videofilename");
VideoView vv = new VideoView(getApplicationContext());
setContentView(vv);
vv.setVideoPath(filename);
vv.setMediaController(new MediaController(this));
vv.requestFocus();
vv.start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, INSERT_ID, 0,"FullScreen");
return true;
}
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch(item.getItemId()) {
case INSERT_ID:
createNote();
}
return true;
}
private void createNote() {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
视频正在从 SD 卡播放。唯一的问题是当我单击全屏菜单按钮时,应用程序“意外停止”。
请帮帮我,如何让视频全屏播放?提前致谢。
最佳答案
全屏播放视频无需代码
在包含 videoview 的 xml 上应用以下布局格式,它肯定会以全屏模式播放视频。因为它正在运行我的 :) 希望它有所帮助
<?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>
关于Android-全屏视频查看,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3776254/