Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

replace grid image with image button

 
Sara Brown
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
however, when doing grid or image button the picture seems have border between each other? is there any other way?
 
Sara Brown
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please, does anybody know how to do?
 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic