1

I heard SO people like diagrams so I took the time to draw one :D

I need to design an activity that roughly looks like the following:

enter image description here

The map is just an image file of city, terrain etc. Users are able to enter values inside the x-coord and y-coord textbox and when both of them have been entered, a triangular icon (also an image file) will appear on top of the map with respect to the coordinates on the map. The min,max of coordinates are fixed as 0,0 to 10000,10000 for all maps. Users can click the triangular icon (button) and it just takes them to another activity.

What is a sensible approach of designing something as above?

As far as I'm concerned, there are several things I need to take into consideration:

1)Mapping the coordinates with respect to the screen size. An obvious workaround for this is to use absolutelayout and use pixels for positioning the triangular icon, but this solution is terrible for obvious reasons.

2)Laying a button on top of the map (image file). After playing around with bunch of layouts, I couldn't figure out how to do this via Java.

I'm just looking for a really simple guidance, just to get myself going in the right direction.

TtT23
  • 6,876
  • 34
  • 103
  • 174

1 Answers1

2

I would use a SurfaceView. You can draw anything in the onDraw method. Youll get a Canvas object to draw on so it shouldn't be difficult to transform your coordinates and do what you want.

take a look at this tutorial:

http://www.mindfiresolutions.com/Using-Surface-View-for-Android-1659.php

Sebastian Breit
  • 6,137
  • 1
  • 35
  • 53
  • Alright, this probably takes good care of the mapping part. Is it possible to create an imagebutton on top of an image at a desired location if I were to place the image inside the surfaceview? – TtT23 Feb 13 '13 at 11:55
  • Yes, but I would rather draw it in the canvas. You can capture the touch events at a given position and see if there is a bitmap ;) – Sebastian Breit Feb 13 '13 at 11:58
  • drawing buttons on top of a Bitmap http://stackoverflow.com/questions/13842191/android-drawing-bitmap-and-button-on-canvas-by-x-y-positions/13842376#13842376 – n3utrino Feb 13 '13 at 12:05