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?
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 view reference from the fragment:
ImageView locationButton = (ImageView) mapFragment.getView().findViewById(2);
Then change it's image to anything you want. e.g.
locationButton.setImageResource(R.drawable.icon_location);
Hope it helps.
I think you can have the "My Location" button view with code below:
View locationButton = ((View) mapView.findViewById(Integer.parseInt("1")).getParent()).findViewById(Integer.parseInt("2"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With