如何在 Android 中更改 GoogleMaps 中的 "Find my location" 图标?

How to change a "Find my location" icon in a GoogleMaps in Android?

如何在 Android 中更改 GoogleMaps 中的 "Find my location" 图标?

我想将此图标更改为自定义。曾尝试使用片段扩展,但可能没有正确的结果。

不确定 "doesn't have a right result" 是什么意思,但这很好用:

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;
        }
    }

}

使用您的自定义布局:

<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"/>

Source