简体   繁体   中英

How to resize the webview According to the size of device Screen in android studio

I've created an android studio project with web view. Web view contains responsive website. I've tested my app with smart phone(nokia3). but I don't know how it works with tab. because I don't have a tablet. but I found some solutions, Can you tell me which one is correct ?

A:

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

B:

WebSettings webSettings = appView.getSettings();
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);

Both are the same. Both are correct in terms of functionality.

You can choose anyone of them.

A. Settings of webview is being modified by directly referencing from the view

B. Its taking the WebSettings object first and then modifying its state.

You can set Webview width and hieght match_parent. but make sure if you set padding then remove the padding.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM