Example usage for android.webkit WebView setVerticalScrollBarEnabled

List of usage examples for android.webkit WebView setVerticalScrollBarEnabled

Introduction

In this page you can find the example usage for android.webkit WebView setVerticalScrollBarEnabled.

Prototype

public void setVerticalScrollBarEnabled(boolean verticalScrollBarEnabled) 

Source Link

Document

Define whether the vertical scrollbar should be drawn or not.

Usage

From source file:jp.mixi.android.sdk.MixiDialog.java

private WebView setUpWebView(WebView webView) {
    Log.v(TAG, "setwebview");
    webView.getSettings().setUserAgentString(Constants.USER_AGENT);
    webView.setVerticalScrollBarEnabled(false);
    webView.setHorizontalScrollBarEnabled(false);
    webView.setWebViewClient(new MixiWebviewClient());

    webView.getSettings().setJavaScriptEnabled(true);
    webView.addJavascriptInterface(new JsHandler(), "mixi");

    String token = mParams.get("oauth_token");
    int sdkInt = Integer.valueOf(Build.VERSION.SDK);
    // android2.1
    if (sdkInt < Constants.SUPPORTED_SDK_VERSION) {
        Uri uri = Uri.parse(mUrl);//from   w  w  w  .  j  a v a2 s. c  om
        if (token != null) {
            Builder builder = uri.buildUpon();
            builder.appendQueryParameter("oauth_token", token);
            uri = builder.build();
        }
        webView.loadUrl(uri.toString());
    } else {
        HashMap<String, String> extraHeaders = new HashMap<String, String>();
        if (token != null) {
            extraHeaders.put("Authorization", "OAuth " + token);
        }
        webView.loadUrl(mUrl, extraHeaders);
    }

    return webView;
}

From source file:com.nextgis.mobile.fragment.AttributesFragment.java

private void setAttributes() {
    if (mAttributes == null)
        return;/*  w ww . ja v a 2 s. c  o  m*/

    mAttributes.removeAllViews();

    int[] attrs = new int[] { android.R.attr.textColorPrimary };
    TypedArray ta = getContext().obtainStyledAttributes(attrs);
    String textColor = Integer.toHexString(ta.getColor(0, Color.BLACK)).substring(2);
    ta.recycle();

    final WebView webView = new WebView(getContext());
    webView.setVerticalScrollBarEnabled(false);
    String data = "<!DOCTYPE html><html><head><meta charset='utf-8'><style>body{word-wrap:break-word;color:#"
            + textColor
            + ";font-family:Roboto Light,sans-serif;font-weight:300;line-height:1.15em}.flat-table{table-layout:fixed;margin-bottom:20px;width:100%;border-collapse:collapse;border:none;box-shadow:inset 1px -1px #ccc,inset -1px 1px #ccc}.flat-table td{box-shadow:inset -1px -1px #ccc,inset -1px -1px #ccc;padding:.5em}.flat-table tr{-webkit-transition:background .3s,box-shadow .3s;-moz-transition:background .3s,box-shadow .3s;transition:background .3s,box-shadow .3s}</style></head><body><table class='flat-table'><tbody>";

    FragmentActivity activity = getActivity();
    if (null == activity)
        return;

    ((MainActivity) activity).setSubtitle(String.format(getString(R.string.features_count_attributes),
            mItemPosition + 1, mFeatureIDs.size()));
    checkNearbyItems();

    try {
        data = parseAttributes(data);
    } catch (RuntimeException e) {
        e.printStackTrace();
    }

    data += "</tbody></table></body></html>";
    webView.loadDataWithBaseURL(null, data, "text/html", "UTF-8", null);
    mAttributes.addView(webView);
    webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            webView.setBackgroundColor(Color.TRANSPARENT);
        }

        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
            return true;
        }
    });

    IGISApplication app = (GISApplication) getActivity().getApplication();
    final Map<String, Integer> mAttaches = new HashMap<>();
    PhotoGallery.getAttaches(app, mLayer, mItemId, mAttaches, false);

    if (mAttaches.size() > 0) {
        final PhotoPicker gallery = new PhotoPicker(getActivity(), true);
        int px = ControlHelper.dpToPx(16, getResources());
        gallery.setDefaultPreview(true);
        gallery.setPadding(px, 0, px, 0);
        gallery.post(new Runnable() {
            @Override
            public void run() {
                gallery.restoreImages(new ArrayList<>(mAttaches.keySet()));
            }
        });

        mAttributes.addView(gallery);
    }
}

From source file:me.piebridge.prevent.ui.UserGuideActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    ThemeUtils.setTheme(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.about);/*w ww. java 2s  .  c o m*/
    ThemeUtils.fixSmartBar(this);
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
        getActionBar().setDisplayHomeAsUpEnabled(true);
    }

    WebView webView = (WebView) findViewById(R.id.webview);
    webView.setVerticalScrollBarEnabled(false);
    webView.setHorizontalScrollBarEnabled(false);
    if ("zh".equals(Locale.getDefault().getLanguage())) {
        webView.loadUrl("file:///android_asset/about.zh.html");
    } else {
        webView.loadUrl("file:///android_asset/about.en.html");
    }
    setView(R.id.alipay, "com.eg.android.AlipayGphone");
    if (hasPermission()) {
        setView(R.id.wechat, "com.tencent.mm");
    } else {
        findViewById(R.id.wechat).setVisibility(View.GONE);
    }
    if (!setView(R.id.paypal, "com.paypal.android.p2pmobile")) {
        TextView paypal = (TextView) findViewById(R.id.paypal);
        paypal.setClickable(true);
        paypal.setOnClickListener(this);
        paypal.setCompoundDrawablesWithIntrinsicBounds(null, cropDrawable(paypal.getCompoundDrawables()[1]),
                null, null);
    }
    if (setView(R.id.play, "com.android.vending")) {
        findViewById(R.id.play).setVisibility(View.GONE);
        checkDonate();
    }
    donateView = findViewById(R.id.donate);
    if (BuildConfig.DONATE && TextUtils.isEmpty(LicenseUtils.getLicense(this))) {
        donateView.setVisibility(View.VISIBLE);
    } else {
        donateView.setVisibility(View.GONE);
    }
    retrieveInfo();
}

From source file:com.near.chimerarevo.fragments.PostFragment.java

@SuppressLint("SetJavaScriptEnabled")
private void addWebObject(String width, String height, String url) {
    WebView wv = new WebView(getActivity());
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

    wv.setLayoutParams(params);/*from ww w  .  j av  a 2s .c o  m*/
    wv.getSettings().setUseWideViewPort(true);
    wv.getSettings().setLoadWithOverviewMode(true);
    wv.getSettings().setSupportZoom(false);
    wv.setVerticalScrollBarEnabled(true);
    wv.setHorizontalScrollBarEnabled(true);
    wv.getSettings().setJavaScriptEnabled(true);
    wv.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    wv.setWebViewClient(new WebViewClient());

    String frame = "<iframe width=\"" + width + "\" height=\"" + height + "\" frameborder=\"0\" src=\"" + url
            + "\"/>";
    wv.loadDataWithBaseURL(url, frame, "html/plain", "UTF-8", null);
    lay.addView(wv);
}

From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java

@SuppressLint("NewApi")
final private void aboutTaskAutomation() {
    // common ??//from w  ww  .j a  va 2s .  c  o  m
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.about_dialog);
    ((TextView) dialog.findViewById(R.id.about_dialog_title))
            .setText(getString(R.string.msgs_about_dlg_title) + " Ver " + getApplVersionName());
    final WebView func_view = (WebView) dialog.findViewById(R.id.about_dialog_function);
    //       func_view.setWebViewClient(new WebViewClient());
    //       func_view.getSettings().setJavaScriptEnabled(true); 
    func_view.getSettings().setSupportZoom(true);
    //      func_view.setVerticalScrollbarOverlay(true);
    func_view.setBackgroundColor(Color.LTGRAY);
    //      func_view.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
    func_view.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET);
    func_view.setVerticalScrollBarEnabled(true);
    func_view.setScrollbarFadingEnabled(false);
    if (Build.VERSION.SDK_INT > 10) {
        func_view.getSettings().setDisplayZoomControls(true);
        func_view.getSettings().setBuiltInZoomControls(true);
    } else {
        func_view.getSettings().setBuiltInZoomControls(true);
    }
    func_view.loadUrl("file:///android_asset/" + getString(R.string.msgs_about_dlg_func_html));

    final WebView change_view = (WebView) dialog.findViewById(R.id.about_dialog_change_history);
    if (Build.VERSION.SDK_INT > 10) {
        func_view.getSettings().setDisplayZoomControls(true);
        func_view.getSettings().setBuiltInZoomControls(true);
    } else {
        func_view.getSettings().setBuiltInZoomControls(true);
    }
    change_view.loadDataWithBaseURL("file:///android_asset/", getString(R.string.msgs_about_dlg_change_desc),
            "text/html", "UTF-8", "");
    change_view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    change_view.getSettings().setSupportZoom(true);
    if (Build.VERSION.SDK_INT > 10) {
        change_view.getSettings().setDisplayZoomControls(true);
        change_view.getSettings().setBuiltInZoomControls(true);
    } else {
        change_view.getSettings().setBuiltInZoomControls(true);
    }

    final Button btnFunc = (Button) dialog.findViewById(R.id.about_dialog_btn_show_func);
    final Button btnChange = (Button) dialog.findViewById(R.id.about_dialog_btn_show_change);
    final Button btnOk = (Button) dialog.findViewById(R.id.about_dialog_btn_ok);

    func_view.setVisibility(TextView.VISIBLE);
    change_view.setVisibility(TextView.GONE);
    btnChange.setBackgroundResource(R.drawable.button_back_ground_color_selector);
    btnFunc.setBackgroundResource(R.drawable.button_back_ground_color_selector);
    btnChange.setTextColor(Color.DKGRAY);
    btnFunc.setTextColor(Color.GREEN);
    btnFunc.setEnabled(false);

    CommonDialog.setDlgBoxSizeLimit(dialog, true);

    // func?
    btnFunc.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            change_view.setVisibility(TextView.GONE);
            func_view.setVisibility(TextView.VISIBLE);
            CommonDialog.setDlgBoxSizeLimit(dialog, true);
            btnFunc.setTextColor(Color.GREEN);
            btnChange.setTextColor(Color.DKGRAY);
            btnChange.setEnabled(true);
            btnFunc.setEnabled(false);
        }
    });

    // change?
    btnChange.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            change_view.setVisibility(TextView.VISIBLE);
            func_view.setVisibility(TextView.GONE);
            CommonDialog.setDlgBoxSizeLimit(dialog, true);
            btnChange.setTextColor(Color.GREEN);
            btnFunc.setTextColor(Color.DKGRAY);
            btnChange.setEnabled(false);
            btnFunc.setEnabled(true);
        }
    });

    // OK?
    btnOk.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
    // Cancel?
    dialog.setOnCancelListener(new Dialog.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface arg0) {
            btnOk.performClick();
        }
    });
    //      dialog.setOnKeyListener(new DialogOnKeyListener(context));
    //      dialog.setCancelable(false);
    dialog.show();

}