Answer the question
In order to leave comments, you need to log in
How to add YouTube fullscreen to WebView?
In one of the fragments of the program there is a WebView that opens YouTube, but for some reason there is no "expand to full screen" button, how to add it?
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class YouTubeFragment extends Fragment {
public YouTubeFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
((MainActivity)getActivity()).setActionBarTitle("YOUTUBE");
View v = inflater.inflate(R.layout.fragment_you_tube, container, false);
WebView webView = (WebView)v.findViewById(R.id.web3);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl("https://www.youtube.com/");
WebSettings webSettings = webView.getSettings();
webSettings.setDomStorageEnabled(true);
webSettings.setLoadWithOverviewMode(true); webSettings.setUseWideViewPort(true);
webSettings.setSupportZoom(true);
return v;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question