【问题标题】:How to change a "Find my location" icon in a GoogleMaps in Android?如何在 Android 的 GoogleMaps 中更改“查找我的位置”图标?
【发布时间】:2015-01-03 17:32:59
【问题描述】:

如何在 Android 的 GoogleMaps 中更改“查找我的位置”图标?

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

【问题讨论】:

    标签: android google-maps location


    【解决方案1】:

    不确定您所说的“没有正确的结果”是什么意思,但这很好用:

    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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-06
      • 1970-01-01
      • 2022-01-10
      • 1970-01-01
      • 2013-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多