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