English 中文(简体)
Android Drag移动图像,但需要整个观点才能移动
原标题:Android - TouchDrag moves image within view, but need entire view to move
  • 时间:2011-11-22 02:09:11
  •  标签:
  • java
  • android

我的形象只是根据接触地点,在我的形象观点中移动。 我需要整个观点(不仅仅是其中的形象)。

Here is my code in onTouch:

ImageView image = (ImageView)v;

    switch (event.getAction() & MotionEvent.ACTION_MASK)
    {
    case MotionEvent.ACTION_DOWN:
        savedMatrix.set(matrix);
        start.set(event.getX(),event.getY());
        mode = DRAG;
        break;
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_POINTER_UP:
        mode = NONE;
        break;
    case MotionEvent.ACTION_MOVE:
        if (mode == DRAG)
        {
            matrix.set(savedMatrix);
            matrix.postTranslate(event.getX() - start.x, event.getY() - start.y);
        }
        break;
    }
    image.setImageMatrix(matrix);

    return true;
最佳回答

Of course it s only the image that moves because you re doing it by calling setImageMatrix on the ImageView. If you want the entire view to move, you can try using a manipulating a canvas with the view that you want.

http://android-developers.blogspot.com 201006/making-sense-of-multitouch.html” http://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.html

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签