MikeTheStudent MikeTheStudent - 1 year ago 171
Android Question

GridLayout directly on the ImageView - android

this is my first post here, so please forgive me for the possible trivialness of the problem.

So I'm trying to create my first android app which is basically a navigation system of a closed area. I want to mark a route from point A to B on a picture of a map using red dots.

As a non-experienced android programmer i came up with a solution:
GridLayout on an ImageView - a grid would be filled with dots that are not visible and the chosen ones would be set to visible (I got the choosing part sorted out).
The point is I don't know a way of positioning them directly one on another. As of right now the dots are appearing from the top of the screen while the map is centered.

Coping with different screen sizes is another matter that will probably require some further try and fail method once the alignment thing is sorted out.

Thanks for any feedback!

Answer Source

Okay, so I managed to solve my little problem: I had to add android:adjustViewBounds="true" to the ImageView. This way the boundaries of the image are on it, not on the layout. Then I could align the GridLayout - android:layout_alignTop="@id/map"

        android:src="@drawable/dot" />

Also I'm using RelativeLayout to do so

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download