Tips for nested large-area blank space in Android WebView and ScrollView

Source: Internet
Author: User
I recently used WebView and encountered the following problems during usage. I 'd like to share with you. First, let's take a look at the webView Width Control Method: This is an API description of this method: when false, the width of this WebView is always the width controlled by CSS on the Web page, therefore, to adapt to the screen, this method must be true. API Description: This loading mode is reduced.

I recently used WebView and encountered the following problems during usage. I 'd like to share with you. First, let's take a look at the webView Width Control Method: This is an API description of this method: when false, the width of this WebView is always the width controlled by CSS on the Web page, therefore, to adapt to the screen, this method must be true. API Description: This loading mode is reduced.

I recently used WebView and encountered the following problems during usage. I 'd like to share with you.

First, let's take a look at the method to control the webView width:

This is an API description of this method: when false, the width of this WebView is always the width controlled in the CSS of the Web page. Therefore, to adapt to the screen, this method must be true.

API Description: This loading mode is used to narrow down the content to adapt to the screen width.

Therefore, when WebView adapts to the screen, set both methods to true.

How to load web pages:

LoadUrl (String url) directly loads the domain name of a page

LoadData (String data, String mimeType, String encoding) loads an HTML segment, mimeType = "text/html" encoding = "UTF-8"

LoadDataWithBaseURL (String baseUrl, String data, String mimeType, String encoding, String historyUrl) is used in the same way as above


I learned about Android WebView attributes and methods related to width adaptation, and tried to get the height settings of webView, which did not achieve satisfactory results.

Back to the question, I used the following tips to barely achieve the desired effect in order to solve the problem of a large area of white space, but the price is to give up the scaling of webView. If any of you have a good solution, please kindly advise.

wv.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);wv.setVerticalScrollBarEnabled(false);wv.setVerticalScrollbarOverlay(false);wv.setHorizontalScrollBarEnabled(false);wv.setHorizontalScrollbarOverlay(false);


Disable the horizontal and vertical scrollBar of the webView, and no longer conflict with the ScrollView.


Zookeeper

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.