How to change a "Find my location" icon in a GoogleMaps in Android?
I want to change this icon to custom. Had tried with a Fragment extending, but probably doesn't have a right result.
How to change a "Find my location" icon in a GoogleMaps in Android?
I want to change this icon to custom. Had tried with a Fragment extending, but probably doesn't have a right result.
Not sure what you mean by "doesn't have a right result" but this works fine:
public class MapsActivity extends FragmentActivity {
...
public static class MapFragment extends SupportMapFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
View locationButton = ((View) view.findViewById(1).getParent()).findViewById(2);
if (locationButton != null) {
Drawable drawable = getActivity().getApplicationContext()
.getResources().getDrawable(R.drawable.ic_launcher);
locationButton.setBackgroundDrawable(drawable);
}
return view;
}
}
}
Using your custom layout:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map"
android:name="com.example.map.MapsActivity$MapFragment"/>