my dog learned polymorphism*
The moose likes Android and the fly likes replace grid image with image button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "replace grid image with image button" Watch "replace grid image with image button" New topic
Author

replace grid image with image button

Sara Brown
Ranch Hand

Joined: Feb 22, 2012
Posts: 55
im curios.

my project need user to mark any part of the picture that related to user's spec.
then it will send to server and the server can see the picture that been mark by the user.

im thinking of, can i use button instead of grid? this button will be put together and it will appears as the real picture.

is this option efficient?
Sara Brown
Ranch Hand

Joined: Feb 22, 2012
Posts: 55
however, when doing grid or image button the picture seems have border between each other? is there any other way?
Sara Brown
Ranch Hand

Joined: Feb 22, 2012
Posts: 55
please, does anybody know how to do?
Darrin Smith
Ranch Hand

Joined: Aug 04, 2003
Posts: 276
You don't need to use buttons.

I suggest that you do this:

1) Use an ImageView
2) Set android:scaleType="matrix"
3) Implement your own OnTouchListener
4) Override onTouch
5) In onTouch look for these cases:
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP:
mode = NONE;
float[] coords = getPointerCoords(view, rawEvent); //view is passed to onTouch
imagePt.x = coords[0];
imagePt.y = coords[1];
6) Make getPointerCoords(view, rawEvent) look like this:

final float[] getPointerCoords(ImageView view, MotionEvent e)
{
final int index = e.getActionIndex();
final float[] coords = new float[] { e.getX(index), e.getY(index) };
Matrix matrix = new Matrix();
view.getImageMatrix().invert(matrix);
matrix.postTranslate(view.getScrollX(), view.getScrollY());
matrix.mapPoints(coords);
return coords;
}



That will return the point upon where the image was touched.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: replace grid image with image button
 
Similar Threads
Image on a button in jsf
Writing a pixel mapping program
Convert InputStream to a File in Memory
How to get image on a button using applet
Image resizing