枪王放大上的ImageViewImageView

2023-09-04 06:26:08 作者:你比狗现实丶

我想实现在一个ImageView的,类似于在iOS内置的照片应用程序(我没有一个物理的Andr​​oid设备做一个更合适的类比)变焦功能。双指缩放将是不错的,但放大的双击是必不可少的。

我已经尝试了一些样品code(例如: HTTP ://android-journey.blogspot.com/2010/01/android-gestures.html ),但是这并没有为我工作,出于某种原因;没有任何事件处理程序火灾(我可能会忽略的东西简单吗?)。

有人点我在正确的方向?

为了排除故障,我用的是Android 2.3模拟器样品code从上面的链接修改,在应用程序与Android:的m​​inSdkVersion = 7,以下布局:

 < XML版本=1.0编码=UTF-8&GT?;
< ImageView的
的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    机器人:SRC =@可绘制/安卓
    机器人:ID =@ + ID /图像
    />
 

解决方案

根据不同的应用需求,你可能要考虑让图像中的web视图加载。这有所有的浏览器的功能(捏如果有的话,双击放大缩小,叠加按钮来放大/缩小。你只需要加载与标签指的是手机上的图像的HTML

I am trying to implement zoom functionality on an ImageView, similar to the built-in Photos app on iOS (I don't have a physical android device to make a more suitable analogy). Pinch-to-zoom would be nice to have, but zoom on double-tap is essential.

王者荣耀无敌孙尚香,一枪一个人头,后期枪王打到让你招呼不住

I've tried some sample code (ex. http://android-journey.blogspot.com/2010/01/android-gestures.html), but this does not work for me, for some reason; none of the event handlers fire (I may be omitting something simple?).

Can someone point me in the right direction?

For troubleshooting purposes, I used sample code unmodified from the above link, on an Android 2.3 emulator in an application with android:minSdkVersion=7 and the following layout:

<?xml version="1.0" encoding="utf-8"?>
<ImageView  
xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:src="@drawable/android"
    android:id="@+id/image"
    />

解决方案

Depending on the application's requirements, you might want to consider having the Image be loaded in a webview. This has all of the functionality of a browser (pinch to zoom if available, double tap to zoom, overlayed buttons to zoom/zoom out. You just need to load the html with the tag referring to the image on the phone.