Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/193.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 全屏安卓视频视图_Android_Video_Fullscreen - Fatal编程技术网

Android 全屏安卓视频视图

Android 全屏安卓视频视图,android,video,fullscreen,Android,Video,Fullscreen,我正在尝试使此视频视图以全屏模式显示: 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);

我正在尝试使此视频视图以全屏模式显示:

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卡上播放。唯一的问题是,当我点击全屏菜单按钮时,应用程序“意外停止”


请帮助我,如何让视频全屏运行?提前感谢。

当您单击菜单项时。你必须开始一项新的活动。对于该活动,必须在清单中设置主题属性。将此值设置为

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

就这样。

在全屏模式下播放视频不需要代码

在包含videoview的xml上应用以下布局格式,它肯定会以全屏模式播放视频。因为它正在运行我的:)希望它有帮助
可能是因为您必须添加以下代码:

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(
    WindowManager.LayoutParams.FLAG_FULLSCREEN,  
     WindowManager.LayoutParams.FLAG_FULLSCREEN);

设置内容视图(您的内容视图)
之前,删除应用程序标题栏。我知道这是一个很晚的答复,但有人可能会发现它很有用。

好的,让我们这样试试,这适合我的全屏

    android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
纵向布局

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:background="@android:color/black">
    <VideoView
        android:id="@+id/video_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center" />
</FrameLayout>

景观布局

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/black">
    <VideoView
        android:id="@+id/video_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="center"/>
</FrameLayout>


根据我的经验,您只能使用相对布局视图在纵向和横向上拉伸视频。线性布局视图只能在横向上拉伸视频,您可以在不编写任何代码的情况下尝试两种视图,并证明我的理论

对于执行相同的操作,当按下全屏模式按钮时,可以使用代码应用上述布局。这对我来说非常有用。这将填补应用程序窗口的可用宽度和高度。您仍然会在应用程序标题栏的顶部显示系统图标(日期/时间电池状态等)。这里的潜台词是,他希望视频填满整个屏幕。嗨,javanator,我在videoview中播放视频并在平板电脑中运行时也面临同样的问题。我已经使用了你的解决方案,但它仍然在平板电脑中有中央对齐的视频,左右两侧都有两条黑线。怎么办。这是我的问题。这也许不是,这是肯定的……)2017年,仍然有用,永不迟到:P
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/black">
    <VideoView
        android:id="@+id/video_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="center"/>
</FrameLayout>