我有一个webview里面有html视频.我想全屏显示这个视频,所以我覆盖了我的WebChromeClient的onShowCustomView以使用VideoView.这在2.3中工作得很好,但是在4.x onShowCustomView中永远不会被调用.视频仍然会播放,但是,除了点击播放和停止之外,它还可以在webview中播放而无需任何控制.
另外,我有hardwareAccelerated =“true”.
知道为什么永远不会调用onShowCustomView吗?
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); webView = (WebView) findViewById(R.id.webView); webView.getSettings().setSupportZoom(true); webView.getSettings().setLoadWithOverviewmode(true); webView.getSettings().setUseWideViewPort(true); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setDomStorageEnabled(true); webView.getSettings().setPluginState(WebSettings.PluginState.ON); webView.setWebViewClient(new WebViewClient()); webView.setWebChromeClient(new MyChromeClient()); webView.loadUrl(URL); } private class MyChromeClient extends WebChromeClient implements OnCompletionListener,OnErrorListener,OnPreparedListener { @Override public void onShowCustomView(View view,CustomViewCallback callback) { Log.d("ma","onShowCustomView"); } ...