当前位置: 首页>>代码示例>>Java>>正文


Java WebView.setInitialScale方法代码示例

本文整理汇总了Java中android.webkit.WebView.setInitialScale方法的典型用法代码示例。如果您正苦于以下问题:Java WebView.setInitialScale方法的具体用法?Java WebView.setInitialScale怎么用?Java WebView.setInitialScale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.webkit.WebView的用法示例。


在下文中一共展示了WebView.setInitialScale方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initWebView

import android.webkit.WebView; //导入方法依赖的package包/类
private static void initWebView(WebView webview) {
    webview.setFocusable(true);
    webview.setInitialScale(0); // imdb does not look good in fullscreen with anything but this
    webview.getSettings().setJavaScriptEnabled(true);
    webview.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (DBG) Log.d(TAG, "shouldOverrideUrlLoading " + url);
            return false;
        }
    });
    // Remove 'Mobile' from the user agent to avoid phone-version of IMDB on TV screen...
    String userAgent = webview.getSettings().getUserAgentString();
    userAgent = userAgent.replace("Mobile", " ");
    webview.getSettings().setUserAgentString(userAgent);
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:17,代码来源:WebViewActivity.java

示例2: onCreateView

import android.webkit.WebView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater li, ViewGroup vg, Bundle b) {
    super.onCreateView(li, vg, b);
    Log.i(TAG, "called super...");

    View rootView = li.inflate(R.layout.fragment_website, vg, false);
    Log.i(TAG, "inflated view...");

    mPlayerManualWeb = (WebView) rootView.findViewById(R.id.website_web_view);
    Log.i(TAG, "instantiated WebView...");

    //1 if portrait 2 if landscape
    int orientation = getActivity().getResources().getConfiguration().orientation;


    mPlayerManualWeb.setInitialScale(orientation * 100);
    mPlayerManualWeb.getSettings().setBuiltInZoomControls(true);
    mPlayerManualWeb.loadUrl(mManualUrl);
    Log.i(TAG, "performed loadUrl...");

    return rootView;

}
 
开发者ID:CIS-Extra,项目名称:mazes_and_minotaurs,代码行数:24,代码来源:WebsiteFragment.java

示例3: CustomWebViewClient

import android.webkit.WebView; //导入方法依赖的package包/类
/**
 * Constructor.
 * @param activity Activity to manage intents.
 * @param wv <code>WebView</code> where web site will be shown.
 * @param url URL address where it is hosted.
 * @param urlBase URL main address.
 * @param initialScale Initial zoom (0 is default).
 */
@SuppressLint("SetJavaScriptEnabled")
public CustomWebViewClient(Activity activity, WebView wv, String url, String urlBase, UrlCache urlCache, int initialScale) {
    this.activity = activity;
    this.wv = wv;
    this.url = url;
    this.urlBase = urlBase;
    this.initialScale = initialScale;
    this.urlCache = urlCache;

    WebSettings settings = wv.getSettings();
    settings.setJavaScriptEnabled(true); // We enable Javascript by default, due to it is needed by lots of websites

    wv.loadUrl(url);
    wv.setInitialScale(initialScale);
}
 
开发者ID:GabrielMorenoIbarra,项目名称:BackendDrivenMenu,代码行数:24,代码来源:CustomWebViewClient.java

示例4: onScaleChanged

import android.webkit.WebView; //导入方法依赖的package包/类
@Override
public void onScaleChanged(WebView view, float oldScale, float newScale) {
    super.onScaleChanged(view, oldScale, newScale);
    if (newScale - oldScale > 7) {
        view.setInitialScale((int) (oldScale / newScale * 100)); //异常放大,缩回去。
    }
}
 
开发者ID:joelan,项目名称:ClouldReader,代码行数:8,代码来源:MyWebViewClient.java

示例5: onScaleChanged

import android.webkit.WebView; //导入方法依赖的package包/类
@Override
public void onScaleChanged(WebView view, float oldScale, float newScale) {


    if (AgentWebUtils.isOverriedMethod(mWebViewClient, "onScaleChanged", WEBVIEWCLIENTPATH + ".onScaleChanged", WebView.class, float.class, float.class)) {
        super.onScaleChanged(view, oldScale, newScale);
        return;
    }

    LogUtils.i(TAG, "onScaleChanged:" + oldScale + "   n:" + newScale);
    if (newScale - oldScale > CONSTANTS_ABNORMAL_BIG) {
        view.setInitialScale((int) (oldScale / newScale * 100));
    }

}
 
开发者ID:Justson,项目名称:AgentWeb,代码行数:16,代码来源:DefaultWebClient.java

示例6: DisplayTemperatureDialog

import android.webkit.WebView; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
public void DisplayTemperatureDialog(@NonNull String url) {
    final Dialog dialog = createDialog();
    dialog.setContentView(R.layout.dialog_webview);

    TextView titleView = dialog.findViewById(R.id.dialog_title_text_view);
    titleView.setText("Temperature Graph");

    com.rey.material.widget.Button closeButton = dialog.findViewById(R.id.dialog_button_close);
    closeButton.setOnClickListener(v -> dialog.dismiss());

    if (!url.startsWith("http://") && !url.startsWith("https://")) {
        url = "http://" + url;
    }

    WebView webview = dialog.findViewById(R.id.dialog_webview);

    webview.getSettings().setUseWideViewPort(true);
    webview.getSettings().setBuiltInZoomControls(true);
    webview.getSettings().setSupportZoom(true);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.getSettings().setLoadWithOverviewMode(true);
    webview.setWebViewClient(new WebViewClient());
    webview.setInitialScale(100);

    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setAcceptCookie(false);

    webview.loadUrl(url);

    displayDialog(dialog);
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:33,代码来源:DialogController.java

示例7: onScaleChanged

import android.webkit.WebView; //导入方法依赖的package包/类
@Override
public void onScaleChanged(WebView view, float oldScale, float newScale) {
    super.onScaleChanged(view, oldScale, newScale);
    if (newScale - oldScale > 7) {
        view.setInitialScale((int) (oldScale / newScale * 100));    //异常放大,缩回去。
    }
}
 
开发者ID:yangchong211,项目名称:YCUtils,代码行数:8,代码来源:KnowledgeOtherFragment.java

示例8: onScaleChanged

import android.webkit.WebView; //导入方法依赖的package包/类
@Override
public void onScaleChanged(WebView view, float oldScale, float newScale) {
    super.onScaleChanged(view, oldScale, newScale);
    if (newScale - oldScale > 7) {
        //异常放大,缩回去。
        view.setInitialScale((int) (oldScale / newScale * 100));
    }
}
 
开发者ID:jutao,项目名称:GankReader,代码行数:9,代码来源:MyWebViewClient.java

示例9: setUpWebViewDefaults

import android.webkit.WebView; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setUpWebViewDefaults(WebView webView) {
    WebSettings settings = webView.getSettings();

    // 网页内容的宽度是否可大于WebView控件的宽度
    settings.setLoadWithOverviewMode(false);
    // 保存表单数据
    settings.setSaveFormData(true);
    // 是否应该支持使用其屏幕缩放控件和手势缩放
    settings.setSupportZoom(true);
    settings.setBuiltInZoomControls(true);
    settings.setDisplayZoomControls(false);
    // 启动应用缓存
    settings.setAppCacheEnabled(true);
    // 设置缓存模式
    settings.setCacheMode(WebSettings.LOAD_DEFAULT);
    // setDefaultZoom  api19被弃用
    // 设置此属性,可任意比例缩放。
    settings.setUseWideViewPort(true);
    // 缩放比例 1
    webView.setInitialScale(1);
    // 告诉WebView启用JavaScript执行。默认的是false。
    settings.setJavaScriptEnabled(true);
    //  页面加载好以后,再放开图片
    settings.setBlockNetworkImage(false);
    // 使用localStorage则必须打开
    settings.setDomStorageEnabled(true);
    // 排版适应屏幕
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
    // WebView是否支持多个窗口。
    settings.setSupportMultipleWindows(true);

    // webview从5.0开始默认不允许混合模式,https中不能加载http资源,需要设置开启。
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }

    /** 设置字体默认缩放大小(改变网页字体大小,setTextSize  api14被弃用)*/
    settings.setTextZoom(100);

    // Enable remote debugging via chrome://inspect
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        WebView.setWebContentsDebuggingEnabled(true);
    }

    // AppRTC requires third party cookies to work
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setAcceptThirdPartyCookies(webView, true);


}
 
开发者ID:zhao-mingjian,项目名称:qvod,代码行数:52,代码来源:WebViewPresenter.java


注:本文中的android.webkit.WebView.setInitialScale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。