bha*_*thi 25 video android fullscreen
我想让这个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);
}
}
Run Code Online (Sandbox Code Playgroud)
该视频正在播放sdcard.唯一的事就是当我点击全屏菜单按钮时,应用程序"意外停止".
请帮帮我,如何让视频全屏运行?提前致谢.
Jav*_*tor 39
无需代码即可在全屏模式下播放视频
<?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>
Run Code Online (Sandbox Code Playgroud)
Pra*_*een 36
单击菜单项时.你必须开始新的活动.对于该Activity,您必须在Manifest中设置theme属性.设置这个值
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
Run Code Online (Sandbox Code Playgroud)
而已.
小智 7
也许是因为你必须添加以下代码:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Run Code Online (Sandbox Code Playgroud)
之前setContentView(your_content_view)摆脱app标题栏.我知道这是一个非常晚的回复,但有人可能会觉得它很有用.
| 归档时间: |
|
| 查看次数: |
79613 次 |
| 最近记录: |