2010-03-02 37 views
3

我想显示大约800 x 800像素的大图像。我希望能够通过用手指拖动来在全部四个方向上平移它。我也想放大和缩小。我需要能够知道平移值和缩放值,因为我必须在图像上的特定位置绘制小文本字符串。关于单幅大图像的pannable-zoomable视图的建议?

例如,如果平移100像素的权利,我需要知道,所以我可以将该偏移量添加到我的所有元素。

想知道做这个的好方法是什么。我是否应该在我实现的View中的paint方法中自己实现它?有没有其他的标准方法呢?它本质上是像谷歌地图查看,只有一个大板砖,但我画我的脚与平移和缩放它的上面,

感谢

+0

你可能想使你有本地拖动到开始与滚动型。它可能会裁剪,因此它一次只显示图像的固定区域。 – 2010-03-03 20:25:18

+0

我期待着做类似的事情。我发现这个https://sites.google.com/site/androidhowto/how-to-1/custom-scrollable-image-view没有运气,但掌握了如何利用,但也许你可以做一些道理。 – taraloca 2011-02-17 17:52:40

回答

0

嗨,大家好,我试图在几个月前没有成功,在最后,我只需要加载一个网页视图中的图像使变焦控制,我能够做我的形象的声像...

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); 

    } 
}