Amina
Amina

Reputation: 723

Draw on a image in a precise position on the screen.

I'm trying to draw a point in a map. I'm detecting the position of some objects, and then displaying a map to the user, where, he can see the position of the objects on the map.

For example if I work with a grid, i know that the first object has the coordinates (1,3) and the second one has the coordinates (4,5). How can I put these object in the image if I know the scale of the image ?

I would like to have a result similar to the given picture, i mean drawing in an image :(This is a screen shot from inseteo application )

enter image description here

Upvotes: 0

Views: 118

Answers (1)

Adhikari Bishwash
Adhikari Bishwash

Reputation: 2780

You can try opensource lib ImageLayout

A layout that arranges its children in relation to a background image.

Example code snippet.Full example project is in git repo of ImageLayout.

Button button = new Button(this);
        ImageLayout.LayoutParams layoutParams = new ImageLayout.LayoutParams();
        layoutParams.left = 243;
        layoutParams.top = 297;
        layoutParams.right = 432;
        layoutParams.bottom = 405;
        button.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.normal_text));
        button.setText(R.string.harlem);
        imageLayout.addView(button, layoutParams);

Link to demo activity code

Upvotes: 1

Related Questions