导入栏在进入和离开视频视图时闪烁

时间:2017-12-14 13:17:56

标签: android

当我使用视频加载视图时,底部的导航栏会暂时闪烁,然后向下滑动以进入沉浸式全屏模式。有没有办法在加载和卸载视图时删除瞬间闪烁? 视频示例 - https://monosnap.com/file/smxhkhctOISN96rOZTaRJ3XtJJ7RP3

此外,我不确定添加视图是否会导致此问题,或者是否在添加媒体播放器时引起该问题。

        dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);


    // Let's create the main dialog
    dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCancelable(true);
    dialog.setOnDismissListener(this);

    // Main container layout
    LinearLayout main = new LinearLayout(cordova.getActivity());
    main.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    main.setOrientation(LinearLayout.VERTICAL);
    main.setHorizontalGravity(Gravity.CENTER_HORIZONTAL);
    main.setVerticalGravity(Gravity.CENTER_VERTICAL);

    videoView = new VideoView(cordova.getActivity());
    videoView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
    dialog.getWindow().getDecorView().setSystemUiVisibility(
                VideoView.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | VideoView.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | VideoView.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                        | VideoView.SYSTEM_UI_FLAG_LOW_PROFILE
                        | VideoView.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
                        | VideoView.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
                        | VideoView.SYSTEM_UI_FLAG_IMMERSIVE
        );
    // videoView.setVideoURI(uri);
    // videoView.setVideoPath(path);
    main.addView(videoView);

    player = new MediaPlayer();
    player.setOnPreparedListener(this);
    player.setOnCompletionListener(this);
    player.setOnErrorListener(this);

这个应用程序播放用户生成的幻灯片幻灯片,从iframe到视频再返回到iframe等等......所以我希望这个过渡是无缝的,不会出现导航栏。

1 个答案:

答案 0 :(得分:0)

我在对话框初始化后添加了标记

dialog.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, 
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);

完整代码现在看起来像这样

protected void openVideoDialog(String path, JSONObject options) {

    dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);

    dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;

    dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
    dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

在更深入地了解对话框在沉浸式模式中的行为后,我找到了这个解决方案reading this article