Example usage for android.webkit WebSettings setBuiltInZoomControls

List of usage examples for android.webkit WebSettings setBuiltInZoomControls

Introduction

In this page you can find the example usage for android.webkit WebSettings setBuiltInZoomControls.

Prototype




public abstract void setBuiltInZoomControls(boolean enabled);

Source Link

Document

Sets whether the WebView should use its built-in zoom mechanisms.

Usage

From source file:io.github.hidroh.materialistic.AppUtils.java

public static void toggleWebViewZoom(WebSettings webSettings, boolean enabled) {
    webSettings.setSupportZoom(enabled);
    webSettings.setBuiltInZoomControls(enabled);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        webSettings.setDisplayZoomControls(false);
    }/*ww  w  .java  2s. co  m*/
}

From source file:de.vanita5.twittnuker.fragment.support.BaseSupportWebViewFragment.java

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    final WebView view = getWebView();
    view.setWebViewClient(new DefaultWebViewClient(getActivity()));
    final WebSettings settings = view.getSettings();
    settings.setBuiltInZoomControls(true);
    settings.setJavaScriptEnabled(true);
    WebSettingsAccessor.setAllowUniversalAccessFromFileURLs(settings, true);
}

From source file:MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    WebView webview = new WebView(this);
    setContentView(webview);/* www. j  a  v a 2 s.  c  o  m*/
    webview.loadUrl("https://www.java2s.com/");
    webview.setWebViewClient(new WebViewClient());

    WebSettings webSettings = webview.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setBuiltInZoomControls(true);
}

From source file:com.dwdesign.tweetings.fragment.WebMapFragment.java

/** Sets up the WebView object and loads the URL of the page **/
private void setupWebView() {

    final WebView webview = getWebView();
    webview.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    setWebViewClient(new MapWebViewClient(getActivity()));
    loadUrl(mUri.toString());//from   w w w .ja  v  a2s. c om

    final WebSettings settings = webview.getSettings();
    settings.setBuiltInZoomControls(false);

    /** Allows JavaScript calls to access application resources **/
    webview.addJavascriptInterface(new JavaScriptInterface(), "android");

}

From source file:in.rab.bildkort.ImageFragment.java

@SuppressLint("SetJavaScriptEnabled")
@Override//from  ww  w  .j  a v  a  2  s .  c  o  m
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mWebView = (WebView) getView().findViewById(R.id.webView);
    final ProgressBar progress = (ProgressBar) getView().findViewById(R.id.image_progress);
    mWebView.setWebChromeClient(new WebChromeClient());
    final WebSettings settings = mWebView.getSettings();

    settings.setBuiltInZoomControls(true);
    settings.setDisplayZoomControls(false);
    settings.setJavaScriptEnabled(true);

    // We replace the src urls in imagepicker.js::init(), so don't load
    // images twice.
    settings.setBlockNetworkImage(true);

    mWebView.setInitialScale(100);

    mWebView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            if (Objects.equals(url, GSTATIC_SERVER)) {
                settings.setBlockNetworkImage(false);

                progress.setVisibility(View.GONE);
                mWebView.setVisibility(View.VISIBLE);
            } else {
                view.loadUrl("javascript:" + getImagePickerJs() + "getPickerHtml();");
            }
        }
    });

    mWebView.addJavascriptInterface(new WcmJsObject(), "wcm");
    mWebView.loadUrl("https://www.google.se/search?tbm=isch&q=" + getWord());
}

From source file:org.que.activities.fragments.WebviewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_webview, container, false);
    if (url != null && !url.isEmpty()) {
        content = ((WebView) rootView.findViewById(R.id.webview));
        //WebViewClient is enabled in order to force all links to load within the webview and also
        // in order to enable JavaScript
        content.setWebViewClient(new HelloWebViewClient());
        WebSettings webSettings = content.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setBuiltInZoomControls(true);
        webSettings.setSupportZoom(true);
        content.loadUrl(url);//  w  ww . j  a va 2s.c o  m
    }

    getActivity().setTitle(title);
    return rootView;
}

From source file:com.rickendirk.rsgwijzigingen.WebFragment.java

@Nullable
@Override/*from  www  .ja  v a2 s .  co  m*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable final Bundle savedInstanceState) {

    View mainView = inflater.inflate(R.layout.fragment_web, container, false);
    if (savedInstanceState != null) {
        is1eKeerGenegeerd = true;
    }
    progressBar = (ProgressBar) getActivity().findViewById(R.id.progressBar);

    webView = (NestedWebView) mainView.findViewById(R.id.webView);
    webView.setNestedScrollingEnabled(true);
    WebSettings webSettings = webView.getSettings();
    webSettings.setBuiltInZoomControls(true);
    webSettings.setDisplayZoomControls(false);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setUseWideViewPort(true);
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            isLoading = true;
            isFinished = false;
            progressBar.setVisibility(View.VISIBLE);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            isFinished = true;
            isLoading = false;
            //Ondestaande if voorkomt weergeven "pagina is vernieuwd" bij orintatie-verandering
            if (is1eKeerGenegeerd) {
                is1eKeerGenegeerd = false;
            } else
                Toast.makeText(getActivity(), "Pagina is vernieuwd", Toast.LENGTH_LONG).show();
            progressBar.setVisibility(View.GONE);
            swipeLayout.setRefreshing(false);
        }
    });
    webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            progressBar.setProgress(newProgress);
            super.onProgressChanged(view, newProgress);
        }
    });
    swipeLayout = (SwipeRefreshLayout) mainView.findViewById(R.id.swipeLayout);
    swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            refresh();
        }
    });
    swipeLayout.setColorSchemeResources(R.color.gmailRood, R.color.orange, R.color.lighter_blue, R.color.green);

    setRetainInstance(true);
    return mainView;

}

From source file:it.rignanese.leo.slimfacebook.PictureActivity.java

private void SetupPictureWebView() {
    webViewPicture = (MyAdvancedWebView) findViewById(R.id.webViewPicture);
    webViewPicture.setListener(this, this);

    //  webViewPicture.setDesktopMode(true);

    //webViewPicture.requestFocus(View.F);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);//remove the keyboard issue

    WebSettings settings = webViewPicture.getSettings();

    settings.setBuiltInZoomControls(true);
    settings.setUseWideViewPort(true);// w w w .jav  a 2s .c o  m
    settings.setJavaScriptEnabled(true);
    settings.setLoadWithOverviewMode(true);

    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
        // Hide the zoom controls for HONEYCOMB+
        settings.setDisplayZoomControls(false);
    }
}

From source file:com.btmura.android.reddit.app.LoginFragment.java

private void setupWebView() {
    // Clear reddit cookie to present a fresh login form.
    CookieManager.getInstance().setCookie(".reddit.com", "reddit_session=");

    WebSettings settings = webView.getSettings();
    settings.setBuiltInZoomControls(true);
    settings.setDisplayZoomControls(false);
    settings.setLoadWithOverviewMode(true);
    settings.setSupportZoom(true);/*from  w ww . j a  va2 s .co  m*/
    settings.setUseWideViewPort(true);

    // Don't save usernames entered into the login forms.
    settings.setSaveFormData(false);

    webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            if (progressBar != null) {
                progressBar.setVisibility(View.VISIBLE);
            }
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            if (progressBar != null) {
                progressBar.setVisibility(View.GONE);
            }
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            // WebView will show an unrecognized scheme error unless we intercept
            // the OAuth callback URL and fire off an intent instead.
            return url != null && url.startsWith(Urls.OAUTH_REDIRECT_URL) && handleOAuthRedirectUrl(url);
        }
    });

    webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            if (progressBar != null) {
                progressBar.setProgress(newProgress);
            }
        }
    });
}

From source file:de.zell.android.util.fragments.WebviewFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_webview, container, false);
    if (url != null && !url.isEmpty()) {
        content = ((WebView) rootView.findViewById(R.id.webview));
        //WebViewClient is enabled in order to force all links to load within the webview and also
        // in order to enable JavaScript
        content.setWebViewClient(new HelloWebViewClient());
        WebSettings webSettings = content.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setBuiltInZoomControls(true);
        webSettings.setSupportZoom(true);

        final ProgressBar progressBar = ((MainNavigationActivity) getActivity()).getProgressBar();
        content.setWebChromeClient(new WebChromeClient() {
            @Override/*from w ww .  j  av a 2 s .c o m*/
            public void onProgressChanged(WebView view, int newProgress) {
                progressBar.setProgress(newProgress);
                if (newProgress == 100)
                    progressBar.setVisibility(View.GONE);
            }
        });

        progressBar.setIndeterminate(true);
        progressBar.setVisibility(View.VISIBLE);
        content.loadUrl(url);
    }

    getActivity().setTitle(title);
    return rootView;
}