Java Code Examples for android.webkit.WebView#setScrollBarStyle()

The following examples show how to use android.webkit.WebView#setScrollBarStyle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HelpFragment.java    From go-bees with GNU General Public License v3.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.help_frag, container, false);

    webView = (WebView) root.findViewById(R.id.webview);

    // Configure related browser settings
    webView.getSettings().setLoadsImagesAutomatically(true);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setUseWideViewPort(true);
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    webView.setWebViewClient(new MyBrowser());

    return root;
}
 
Example 2
Source File: PadViewActivity.java    From padland with Apache License 2.0 6 votes vote down vote up
/**
 * Enables the required settings and features for the webview
 *
 * @param webView
 */
private void _makeWebSettings(WebView webView) {
    webView.setInitialScale(1);
    WebSettings webSettings = webView.getSettings();
    // Enable Javascript
    webSettings.setJavaScriptEnabled(true);
    // remove a weird white line on the right size
    webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);

    webSettings.setUseWideViewPort(true);
    webSettings.setSupportZoom(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setDisplayZoomControls(false);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setDomStorageEnabled(true); // Required for some NodeJS based code
}
 
Example 3
Source File: WeiboDialog.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
private void initWebView()
{
    mWebViewContainer = new RelativeLayout(getContext());
    mWebView = new WebView(getContext());
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setSavePassword(false);
    mWebView.setWebViewClient(new WeiboWebViewClient(null));
    mWebView.requestFocus();
    mWebView.setScrollBarStyle(0);
    mWebView.setVisibility(4);
    NetworkHelper.clearCookies(mContext, mAuthUrl);
    mWebView.loadUrl(mAuthUrl);
    android.widget.RelativeLayout.LayoutParams layoutparams = new android.widget.RelativeLayout.LayoutParams(-1, -1);
    android.widget.RelativeLayout.LayoutParams layoutparams1 = new android.widget.RelativeLayout.LayoutParams(-1, -1);
    DisplayMetrics displaymetrics = getContext().getResources().getDisplayMetrics();
    int i = (int)(10F * displaymetrics.density);
    layoutparams1.setMargins(i, i, i, i);
    Drawable drawable = ResourceManager.getNinePatchDrawable(mContext, 1);
    mWebViewContainer.setBackgroundDrawable(drawable);
    mWebViewContainer.addView(mWebView, layoutparams1);
    mWebViewContainer.setGravity(17);
    int j = 1 + ResourceManager.getDrawable(mContext, 2).getIntrinsicWidth() / 2;
    layoutparams.setMargins(j, (int)(25F * displaymetrics.density), j, j);
    mRootContainer.addView(mWebViewContainer, layoutparams);
}
 
Example 4
Source File: BaseWebActivity.java    From Aurora with Apache License 2.0 5 votes vote down vote up
protected void configWebView() {
    mWebView = new WebView(getApplicationContext());
    mWebViewContainer.addView(mWebView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    WebSettings settings = mWebView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setDefaultTextEncodingName("UTF-8");
    settings.setSupportZoom(false);
    settings.setPluginState(WebSettings.PluginState.ON);
    mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
}
 
Example 5
Source File: BaseWebActivity.java    From Dota2Helper with Apache License 2.0 5 votes vote down vote up
protected void configWebView() {
    mWebView = new WebView(getApplicationContext());
    mWebViewContainer.addView(mWebView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    WebSettings settings = mWebView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setDefaultTextEncodingName("UTF-8");
    settings.setSupportZoom(false);
    settings.setPluginState(WebSettings.PluginState.ON);
    mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
}
 
Example 6
Source File: JSWebView.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
public static void setImage(final WebView webView, final File file) {
    fixWebViewTip(webView.getContext());
    
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
        webView.setDrawingCacheEnabled(true);
    }
    webView.setBackgroundColor(Color.TRANSPARENT);
    webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
        CompatibilityImpl.setScrollbarFadingEnabled(webView, true);
    }
    
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setBuiltInZoomControls(true);
    settings.setSupportZoom(true);
    settings.setAllowFileAccess(true);
    settings.setUseWideViewPort(true);
    settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
        CompatibilityImpl.setBlockNetworkLoads(settings, true);
    }
    
    Runnable setup = new Runnable() {
        @Override
        public void run() {
            String html = String.format(TEMPLATE, Uri.fromFile(file).toString());
            webView.loadDataWithBaseURL(null, html, "text/html", "UTF-8", null);
        }
    };
    
    if (webView.getWidth() > 0) {
        setup.run();
    } else {
        webView.loadData("<html></html>", "text/html", "utf-8");
        AppearanceUtils.callWhenLoaded(webView, setup);
    }
}
 
Example 7
Source File: WebInitCompat.java    From Android_Skin_2.0 with Apache License 2.0 5 votes vote down vote up
@Override
public void setDefaultAttr(WebView view) {
	// 去除滚动条白色背景,必须在代码里面添加才有效
	view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
	view.setScrollbarFadingEnabled(true);
	view.setDrawingCacheEnabled(true);
	view.setLongClickable(true);
	view.setBackgroundResource(android.R.color.transparent);
	view.setBackgroundColor(Color.TRANSPARENT);
	view.getBackground().setAlpha(0);
	view.setFocusable(true);
	view.setFocusableInTouchMode(true);
}
 
Example 8
Source File: AboutDialogPreference.java    From ToGoZip with GNU General Public License v3.0 5 votes vote down vote up
private static WebView setAboutText(Context context, WebView wv) {
    final WebSettings settings = wv.getSettings();

    // Fix for "Wrong charset in serbian translations" https://github.com/k3b/LocationMapViewer/issues/5
    // (for android 2.2) see http://stackoverflow.com/questions/4933069/android-webview-with-garbled-utf-8-characters
    settings.setDefaultTextEncodingName("utf-8");
    settings.setBuiltInZoomControls(true);

    String html = context.getResources().getString(R.string.about_content); // "<html><body>some <b>html</b> here</body></html>";

    final String versionName = GuiUtil.getAppVersionName(context);
    if (versionName != null) {
        html = html.replace("$versionName$", versionName);
    }

    html = html.replace("$translate$",
            context.getText(R.string.about_translate));
    html = html.replace("$about$",
            context.getText(R.string.about_content_about));

    // Fix for "Wrong charset in serbian translations" https://github.com/k3b/LocationMapViewer/issues/5
    // (for android 4.x) see http://stackoverflow.com/questions/4933069/android-webview-with-garbled-utf-8-characters
    wv.loadData(html, "text/html; charset=utf-8", "UTF-8");
    wv.setVerticalScrollBarEnabled(true);

    wv.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
    wv.setScrollbarFadingEnabled(false);
    return wv;
}