【发布时间】:2015-01-03 17:32:59
【问题描述】:
如何在 Android 的 GoogleMaps 中更改“查找我的位置”图标?
我想将此图标更改为自定义。曾尝试使用 Fragment 扩展,但可能没有正确的结果。
【问题讨论】:
标签: android google-maps location
如何在 Android 的 GoogleMaps 中更改“查找我的位置”图标?
我想将此图标更改为自定义。曾尝试使用 Fragment 扩展,但可能没有正确的结果。
【问题讨论】:
标签: android google-maps location
不确定您所说的“没有正确的结果”是什么意思,但这很好用:
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"/>
【讨论】: