I have two questions:
I find this code to use pinch in the webImageView but when I change webImageView by WebView. I obtain an error in the code. how I use pinch in the webview??
// create the WebImageView object from xml
WebImageView img = (WebImageView) findViewById(R.id.main_pic);
// fetches the image in a background thread
img.setImageFromURL("http://www.mysite.com/mypicture.jpg");
// enable pinch-zoom abilities on the image
new PinchImageView(img);
When I add pinch in my code is that supported by all the mobile android or you should have a specific screen to make it work it.
You can enable zooming in a WebView by following WebView setting
mWebView.getSettings().setBuiltInZoomControls(true);
Also you can set the default zoom level by using ZoomDensity
mWebView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.CLOSE);
Have you added the referencing library of Nikko?
http://code.google.com/p/android-pinch/wiki/PinchImageView
Related
Is there any equivalent function in XWalkView for setLoadWithOverviewMode?
I am working on a Android application that load a website in a XWalkView. The view zooms in the top left corner of the website when it loaded. I couldn't find anyway to set the initial zoom level of the XWalkView. As for the android webview, i used setLoadWithOverviewMode for the job, but the xwalk 11 library does not support getSetting() method anymore.
Help would be very much appreciated.
Sorry for my bad english.
In latest versions (I'm on 20.50.529) you can use this to get an initial zoom of 100%
XWalkView webView=new XWalkView(this);
webView.getSettings().setInitialPageScale(100);
I am trying to implement an app where a simple image (floor plan of a room ) is used as a map.
Actually I am not clearly sure about how to do it. But after some searching, I follow one of instructions in a blog.
I am using a WebView to show the image. I am using three different size of the image for three specific zoom level.
There are two button zoomIn and zoomOut. I am just loading a different image when zoom level is changed.
Is it right way?
To enable zoom on the WebView, add the following code:
webView.getSettings().setBuiltInZoomControls(true);
for your button 1:
int zoom_level=100;
webview1.setInitialScale(zoom_level);
webview1.loadData("url");
repeat same for other buttons.
I am trying to make an image map similar to AndroidImageMap. Now, i need to know whether the same implementation with android webview is possible? Because, the image map can be processed in the server side and implemented as HTML image map. If we use to display the HTML image map's URL in a webview, then how can the click events be recognized from the webview co-ordinates clicked?
Note : I need to perform respected action when the corresponding image map co-ordinates clicked.
I am using a Webview to look at a local image with zoom support and all that. Is there any way that I can make the WebView zoom to only fit the height of the image, instead of the width like it does with my current code? Here is what I have:
WebView image = (WebView)findViewById(R.id.map);
image.getSettings().setBuiltInZoomControls(true);
image.getSettings().setLoadWithOverviewMode(true);
image.getSettings().setUseWideViewPort(true);
image.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT));
image.loadUrl("file:///android_asset/image.png");
Try using the webView Settings
use the webSettings class
webview.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);
Check out Set zoom for Webview
Update:
as setDefaultZoom deprecated you need to use another settings
I created an app that has a small image loaded from URL of a website. I want that when user clicks on that small image it'll show the image in full screen and will also have the ability to zoom and pan that image.
What I've done was showing the image in WebView with built-in zoom controls but the result was ugly. (I've set the layout to wrap_content so no white areas are shown, but it cause the image doesn't zoom dynamically).
Any solution? and sorry for my bad English.
Problem solved! For anyone who have the same problem, I've use this library and it works great! http://blog.sephiroth.it/2011/04/04/imageview-zoom-and-scroll/
Here's a link to the Github ImageViewZoom page.
You can build that from scratch or... you can use this library:
http://code.google.com/p/android-pinch
Take a look at the PinchImageView class
You need to use GestureDetectors. Google has excellent sample interactiveChart for this, see https://android.googlesource.com/platform/development/+/master/samples/training/InteractiveChart
and http://developer.android.com/training/gestures/scroll.html