Webview enlargement and reduction-new problems found

Source: Internet
Author: User

Today, we used webview to zoom in and out:

Add code:

WV. getsettings (). setbuiltinzoomcontrols (true); // zoom in and out controler
WV. getsettings (). setsuppzoom zoom (true); // It can be scaled.
WV. getsettings (). setdefaultzoom (zoomdensity. Close); // The default scaling mode is zoomdensity. medium.

The effect is like a map. You can use the Controller to control Scaling (the default position is in the lower right corner. If you want to change the position of the Controller component, you are advised to layout it separately and then use WV. setinitialscale)

Of course, you can also use: WV. setinitialscale (100); // display the ratio of 100%. to enlarge the display, you can change it to a value such as 200,250.

Test today

Problem 1: I tested it on my mobile phone and found that I wanted to make it zoom in and out (like a map). Even if I added the above Code, it was ineffective on my mobile phone, the display on Motorola xoom is effective. I'm dizzy!


Problem 2 found: This method (WV. setinitialscale (250, android development is a bit messy.

It hurts a lot!

The page is written at the backend, and no one in that company knows how to process it in HTML.

Why can Motorola xoom be amplified in this way.


If you find the information, you can set it as follows:

With the density of the current screen, you can dynamically set this attribute to adapt to different screens (of course, by default, your page is designed for the density of 160dpi ):

IntScreendensity =
Getresources (). getdisplaymetrics (). densitydpi;

Websettings. zoomdensity =
Websettings. zoomdensity. medium;

Switch(Screendensity ){

CaseDisplaymetrics. density_low:

Zoomdensity = websettings. zoomdensity. close;

Break;

CaseDisplaymetrics. density_medium:

Zoomdensity = websettings. zoomdensity. medium;

Break;

CaseDisplaymetrics. density_high:

Zoomdensity = websettings. zoomdensity. far;

Break;

}

Webview. getsettings (). setdefazoom zoom (zoomdensity );


.

However, the customer is not satisfied with this display. The reason is that a small black area is left on the right side. It really takes my life.

For the moment, when it belongs to a tablet but not to a Motorola xoom,

Aidhomewebview. getsettings (). setdefazoom zoom (zoomdensity. Close );

No
Setinitialscale

References:

Http://www.iteye.com/topic/1114214

Related Article

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.