Ich habe VideoEnabledWebView in meinem Fragment noch aktiviert, es erscheint keine Vollbild-Schaltfläche in der Webansicht, während ich das Video ansehe, was ist der Grund?Warum erscheint die Vollbild-Schaltfläche nicht in der Webview-Aktivität
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_top_rated, container, false);
String url = "http://youtube.com";
myWebView = (VideoEnabledWebView) rootView.findViewById(R.id.webViewTop);
myWebView.setWebChromeClient(new WebChromeClient());
myWebView.getSettings().setJavaScriptEnabled(true);
progress = (ProgressBar) rootView.findViewById(R.id.progressBar3);
View nonVideoLayout = rootView.findViewById(R.id.nonVideoLayout);
ViewGroup videoLayout = (ViewGroup)rootView.findViewById(R.id.videoLayout);
setHasOptionsMenu(true);
webChromeClient = new VideoEnabledWebChromeClient(nonVideoLayout, videoLayout, myWebView);
myWebView.loadUrl(url);
webChromeClient.setOnToggledFullscreen(new VideoEnabledWebChromeClient.ToggledFullscreenCallback()
{
@Override
public void toggledFullscreen(boolean fullscreen)
{
if (fullscreen)
{
WindowManager.LayoutParams attrs = getActivity().getWindow().getAttributes();
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
attrs.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
getActivity().getWindow().setAttributes(attrs);
if (android.os.Build.VERSION.SDK_INT >= 14)
{
//noinspection all
getActivity().getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
}
}
else
{
WindowManager.LayoutParams attrs = getActivity().getWindow().getAttributes();
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
attrs.flags &= ~WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
getActivity().getWindow().setAttributes(attrs);
if (android.os.Build.VERSION.SDK_INT >= 14)
{
//noinspection all
getActivity().getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
}
}
}
});
myWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView View, String url) {
View.loadUrl(url);
TopRatedFragment.this.progress.setProgress(0);
return true;
}
});
myWebView.setOnKeyListener(new android.view.View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
WebView webView = (WebView) v;
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
if (webView.canGoBack()) {
webView.goBack();
return true;
}
break;
}
}
return false;
}
});
return rootView;
}
}
Hier ist mein Layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/nonVideoLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ProgressBar
android:id="@+id/progressBar3"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="3dip"
android:max="100"
android:progressDrawable="@drawable/greenprogress"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
<com.taadu.slidechat.adaptor.VideoEnabledWebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webViewTop"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/progressBar3"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/videoLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
</RelativeLayout>
Gesuchte Stunden, immer noch nichts zu ermöglichen, Vollbild-Schaltfläche im Zusammenhang finden konnte,
bitte helfen.
UPDATE
diese Bibliothek https://github.com/delight-im/Android-AdvancedWebView
bringt auf Videos im Vollbild-Button Hinzufügen, aber nach der Vollbild-Button klicken, hängt alles zusammen.