android.webkit.WebView.setInitialScale()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(574)

本文整理了Java中android.webkit.WebView.setInitialScale()方法的一些代码示例,展示了WebView.setInitialScale()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebView.setInitialScale()方法的具体详情如下:
包路径:android.webkit.WebView
类名称:WebView
方法名:setInitialScale

WebView.setInitialScale介绍

暂无

代码示例

代码示例来源:origin: Justson/AgentWeb

@Override
public void onScaleChanged(WebView view, float oldScale, float newScale) {
  if (AgentWebUtils.isOverriedMethod(mWebViewClient, "onScaleChanged", ANDROID_WEBVIEWCLIENT_PATH + ".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));
  }
}

代码示例来源:origin: luili16/UIMocker

@Override
public void setInitialScale(int scaleInPercent) {
  mWebView.setInitialScale(scaleInPercent);
}

代码示例来源:origin: stackoverflow.com

WebView webview1 = (WebView) findViewById(R.id.webview1);
webview1.setInitialScale(30);
webview1.loadUrl("http://stackoverflow.com");

代码示例来源:origin: stackoverflow.com

WebView webview1 = (WebView) findViewById(R.id.webview1);
webview1.setInitialScale(90);
webview1.loadUrl("http://stackoverflow.com");

代码示例来源:origin: stackoverflow.com

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

webView.setInitialScale(1);

webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setLoadWithOverviewMode(true);

代码示例来源:origin: stackoverflow.com

public class Main extends Activity {
  WebView webview1;
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.webview);

    webview1 = (WebView)findViewById(R.id.webview01);

    webview1.getSettings().setJavaScriptEnabled(true); 
    webview1.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

    webview1.getSettings().setBuiltInZoomControls(true);
    webview1.setInitialScale(50);
    webview1.loadUrl("http://www.mywebsite.com/"); 

  }
}

代码示例来源:origin: yangchong211/YCAudioPlayer

@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));
  }
}

代码示例来源:origin: laotan7237/EasyReader

@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)); //异常放大,缩回去。
    }
  }
}

代码示例来源:origin: AlarmZeng/BaseProject

@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)); //异常放大,缩回去。
    }
  }
}

代码示例来源:origin: stackoverflow.com

private class MyWebViewClient extends WebViewClient {
  public void onPageFinished(WebView view, String url) {
    view.setInitialScale((int)(100*view.getScale()));
  }
}

代码示例来源:origin: stackoverflow.com

WebView webView=(WebView)this.findViewById(R.id.link4_view);
 webView.getSettings().setBuiltInZoomControls(true);
 webView.getSettings().setUseWideViewPort(true);
 webView.setInitialScale(50);
 webView.loadUrl("http://www.racquetime.com/terms");
     webView.zoomIn();

代码示例来源:origin: stackoverflow.com

public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  WebView mWebView = new WebView(this);

  //now do whatever u want
  mWebView.getSettings().setJavaScriptEnabled(true);
  mWebView.setWebViewClient(new HelloWebViewClient());
  mWebView.loadUrl("http://192.168.1.101/adddrop/index2.php");
  mWebView.setInitialScale(130);

  //finally
  setContentView(mWebView);
}

代码示例来源:origin: stackoverflow.com

WebView wv;
WebSettings webSettings = wv.getSettings();

webSettings.setBuiltInZoomControls(true); //when you define webview settings just add this to enable zoom
wv.setInitialScale(1); //lets set initial zoom to 1% to see whole page when it loads

代码示例来源:origin: vogellacompany/codeexamples-android

public void setText(String url) {
    // Set the scale factor
    webview.setInitialScale(50);
    webview.getSettings().setBuiltInZoomControls(true);
    webview.getSettings().setSupportZoom(true);
    webview.loadUrl(url);
  }
}

代码示例来源:origin: stackoverflow.com

WebView v = (WebView) findViewById(R.id.webView);
v.getSettings().setBuiltInZoomControls(true);
if(Build.VERSION.SDK_INT >= 11) {
  v.getSettings().setDisplayZoomControls(false);
}
v.setInitialScale(100);
v.setBackgroundColor(0x00000000);
v.getSettings().setUseWideViewPort(false);
String html = "<html><head><meta name='viewport' content='width=500, initial-scale=1, minimum-scale=1' /></head>"
    + "<body><img src='file.png' style='width:500px;display:block;margin:0 auto;'/></body></html>";
v.loadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null);

代码示例来源:origin: stackoverflow.com

WebView mWebView = (WebView) findViewById(R.id.webView1);
mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
mWebView.setBackgroundColor(Color.parseColor("#ffffff"));
mWebView.loadUrl("file:///android_asset/image.png");
mWebView.getSettings().setBuiltInZoomControls(true);
mWebView.setInitialScale(50);

代码示例来源:origin: stackoverflow.com

private WebView webView;

  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.web);

    webView = (WebView) findViewById(R.id.web_view);
    webView.setInitialScale(1);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setUseWideViewPort(true);
    webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    webView.setScrollbarFadingEnabled(false);
    webView.loadUrl("http://www.youtube.com");

  }

}

代码示例来源:origin: gearvrf/GearVRf-Demos

private void createWebView() {
  webView = new WebView(this);
  webView.setInitialScale(100);
  webView.setLayoutParams(new ViewGroup.LayoutParams(2000, 1000));
  WebSettings webSettings = webView.getSettings();
  webSettings.setJavaScriptEnabled(true);
  webView.loadUrl("http://gearvrf.org");
  webView.setWebViewClient(new WebViewClient() {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
      view.loadUrl(url);
      return true;
    }
  });
}

代码示例来源:origin: stackoverflow.com

final String mimeType = "text/html";
final String encoding = "utf-8";
String nBody = "PUT YOUR HTML HERE" ;
WebView wv1 = (WebView)findViewById(R.id.wv2);
wv1.setBackgroundColor(Color.WHITE);
wv1.setInitialScale(65);
WebSettings webSettings1 = wv1.getSettings();
webSettings1.setUseWideViewPort(true);
webSettings1.setDefaultFontSize(12);
wv1.loadDataWithBaseURL(null, nBody, mimeType, encoding, null);

代码示例来源:origin: Leeii/LeeFream

@Override
protected void trySetupData(Bundle savedInstanceState) {
  WebViewClient webViewClient = new WebViewClient();
  webView.setWebViewClient(webViewClient);
  webView.clearCache(true);
  webView.getSettings().setUseWideViewPort(true);
  webView.setInitialScale(1);
  webView.getSettings().setBuiltInZoomControls(true);
  webView.clearHistory();
  webView.getSettings().setAllowFileAccess(true);
  webView.getSettings().setDomStorageEnabled(true);
  webView.getSettings().setJavaScriptEnabled(true);
  webView.getSettings().setPluginState(WebSettings.PluginState.ON);
  webView.getSettings().setLoadWithOverviewMode(true);
  webView.getSettings().setUseWideViewPort(true);
  webView.getSettings().setPluginState(WebSettings.PluginState.ON);
  webView.loadUrl("https://github.com/Leeii/LeeFream");
}

相关文章

WebView类方法