1. Process the interception point by configuring the full-screen event of XWalkView
webView.setUIClient(new InjectedXWalkUIClient(webView, mJsCallJava, listener)); public class InjectedXWalkUIClient extends XWalkUIClient { ...... @Override public void onFullscreenToggled(XWalkView view, boolean enterFullscreen) { super.onFullscreenToggled(view, enterFullscreen); Log.e(TAG, "onFullscreenToggled: "+enterFullscreen); // registered callback listener interface if (this.listener != null) { this.listener.onFullscreenToggled(view,enterFullscreen); } } ...... }
2. Process in listener's onFullscreenToggled, core code
this.isFullScreen = enterFullscreen; if (enterFullscreen) { // Set whether the title bar is visible this.common_top_layout.setVisibility(GONE); // landscape this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // full screen settings WindowManager.LayoutParams attrs = getWindow().getAttributes(); attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; this.getWindow().setAttributes(attrs); } else { // Set the title bar to be visible this.common_top_layout.setVisibility(View.VISIBLE); // vertical screen this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // cancel full screen WindowManager.LayoutParams attrs = getWindow().getAttributes(); attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN; this.getWindow().setAttributes(attrs); }