I want to display a large-ish image, around 800 x 800 pixels. I'd like to be able to pan it in all four directions by dragging with a finger. I'd also like to be able to zoom in and out. I need to be able to know the pan values and zoom values, because I have to draw small text strings at certain locations over the image.
For example, if the pan is 100 pixels to the right, I need to know that so I can add that offset to all my elements.
Wondering what a good way to do this is. Should I implement it myself in the paint method within a View I implement? Is there some other standard method of doing it? It's essentially like a google maps view, only one large tile, but I have to draw开发者_开发知识库 my pins on top of it with pan and zoom,
Thanks
Hi guys i tried some months ago with no success, at last i just load the images inside a webview enabling the zoom controls and i was able to do the panning of my image...
public class PhotoZoom extends Activity {
private static final FrameLayout.LayoutParams ZOOM_PARAMS =
new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
Gravity.BOTTOM);
private WebView PhotoZoom;
private long lastTouchTime = -1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.photo_zoom);
PhotoZoom = (WebView) findViewById(R.id.PhotoZoom);
PhotoZoom.setBackgroundColor(Color.BLACK);
Bundle bundle = getIntent().getExtras();
String Photoname = bundle.getString("URLPhoto");
PhotoZoom.loadUrl("content://com.jorgesys.pan/sdcard/myimages/" +fotoname);
WebSettings webSettings = PhotoZoom.getSettings();
webSettings.setSavePassword(false);
webSettings.setSaveFormData(false);
webSettings.setJavaScriptEnabled(true);
webSettings.setSupportZoom(true);
FrameLayout mContentView = (FrameLayout) getWindow().getDecorView().findViewById(android.R.id.content);
View zoom = PhotoZoom.getZoomControls();
mContentView.addView(zoom, ZOOM_PARAMS);
zoom.setVisibility(View.VISIBLE);
}
}
精彩评论