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

The following examples show how to use android.webkit.WebView#setScrollbarFadingEnabled() . 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: 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 2
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;
}
 
Example 3
Source File: LightningView.java    From Xndroid with GNU General Public License v3.0 4 votes vote down vote up
public LightningView(@NonNull Activity activity, @Nullable String url, boolean isIncognito) {
    BrowserApp.getAppComponent().inject(this);
    mActivity = activity;
    mUIController = (UIController) activity;
    mWebView = new WebView(activity);
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
        mWebView.setId(View.generateViewId());
    }
    mIsIncognitoTab = isIncognito;
    mTitle = new LightningViewTitle(activity);

    sMaxFling = ViewConfiguration.get(activity).getScaledMaximumFlingVelocity();

    mWebView.setDrawingCacheBackgroundColor(Color.WHITE);
    mWebView.setFocusableInTouchMode(true);
    mWebView.setFocusable(true);
    mWebView.setDrawingCacheEnabled(false);
    mWebView.setWillNotCacheDrawing(true);
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
        //noinspection deprecation
        mWebView.setAnimationCacheEnabled(false);
        //noinspection deprecation
        mWebView.setAlwaysDrawnWithCacheEnabled(false);
    }
    mWebView.setBackgroundColor(Color.WHITE);

    mWebView.setScrollbarFadingEnabled(true);
    mWebView.setSaveEnabled(true);
    mWebView.setNetworkAvailable(true);
    mWebView.setWebChromeClient(new LightningChromeClient(activity, this));
    mWebView.setWebViewClient(new LightningWebClient(activity, this));
    mWebView.setDownloadListener(new LightningDownloadListener(activity));
    mGestureDetector = new GestureDetector(activity, new CustomGestureListener());
    mWebView.setOnTouchListener(new TouchListener());
    sDefaultUserAgent = mWebView.getSettings().getUserAgentString();
    initializeSettings();
    initializePreferences(activity);

    if (url != null) {
        if (!url.trim().isEmpty()) {
            mWebView.loadUrl(url, mRequestHeaders);
        } else {
            // don't load anything, the user is looking for a blank tab
        }
    } else {
        loadHomepage();
    }
}
 
Example 4
Source File: CompatibilityImpl.java    From Overchan-Android with GNU General Public License v3.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.ECLAIR)
public static void setScrollbarFadingEnabled(WebView webView, boolean fadeScrollbars) {
    webView.setScrollbarFadingEnabled(fadeScrollbars);
}
 
Example 5
Source File: LightningView.java    From JumpGo with Mozilla Public License 2.0 4 votes vote down vote up
public LightningView(@NonNull Activity activity, @Nullable String url, boolean isIncognito) {
    BrowserApp.getAppComponent().inject(this);
    mActivity = activity;
    mUIController = (UIController) activity;
    mWebView = new WebView(activity);
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
        mWebView.setId(View.generateViewId());
    }
    mIsIncognitoTab = isIncognito;
    mTitle = new LightningViewTitle(activity);

    sMaxFling = ViewConfiguration.get(activity).getScaledMaximumFlingVelocity();

    mWebView.setDrawingCacheBackgroundColor(Color.WHITE);
    mWebView.setFocusableInTouchMode(true);
    mWebView.setFocusable(true);
    mWebView.setDrawingCacheEnabled(false);
    mWebView.setWillNotCacheDrawing(true);
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
        //noinspection deprecation
        mWebView.setAnimationCacheEnabled(false);
        //noinspection deprecation
        mWebView.setAlwaysDrawnWithCacheEnabled(false);
    }
    mWebView.setBackgroundColor(Color.WHITE);

    mWebView.setScrollbarFadingEnabled(true);
    mWebView.setSaveEnabled(true);
    mWebView.setNetworkAvailable(true);
    mWebView.setWebChromeClient(new LightningChromeClient(activity, this));
    mLightningWebClient = new LightningWebClient(activity, this);
    mWebView.setWebViewClient(mLightningWebClient);
    mWebView.setDownloadListener(new LightningDownloadListener(activity));
    mGestureDetector = new GestureDetector(activity, new CustomGestureListener());
    mWebView.setOnTouchListener(new TouchListener());
    sDefaultUserAgent = mWebView.getSettings().getUserAgentString();
    initializeSettings();
    initializePreferences(activity);

    if (url != null) {
        if (!url.trim().isEmpty()) {
            mWebView.loadUrl(url, mRequestHeaders);
        } else {
            // don't load anything, the user is looking for a blank tab
        }
    } else {
        loadHomepage();
    }
}