MSH MSH - 11 months ago 113
Android Question

Set custom view for my location button in google map

I am using the Google Maps Android API v2, and I need a way to change the view (icon, color, etc.) of "My Location" button.

now i can change the position of that but i need a way to do a full customization.
can somebody help me please?

MLF MLF
Answer Source

The location button is actually an ImageView. You should first retrieve the fragment view that is associated with the map:

SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                                    .findFragmentById(R.id.map);

Next, you should get location icon reference from the fragment:

ImageView locationButton = (ImageView) mapFragment.getView().findViewById(2);

The change it's image to anything you want. e.g.

locationButton.setImageResource(R.drawable.icon_location);

Hope it helps.