如何更改 Android 中 google 地图片段中的默认蓝色圆形位置图标?
How to change by default blue round location icon in google map fragment in Android?
当我们启用 setMylocationEnabled(true)
时,地图片段上出现的当前位置的蓝色圆形图标需要在我的场景中更改。我怎样才能实现默认情况下出现车辆图标而不是蓝色图标。谢谢。
试试这个,对我有用
ImageView btnMyLocation = (ImageView) ((View) mapFragment.getView().findViewById(Integer.parseInt("1")).getParent()).findViewById(Integer.parseInt("2"));
btnMyLocation.setImageResource(R.drawable.ic_current_location);
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)
btnMyLocation.getLayoutParams();
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
layoutParams.setMargins(0, 0, 30, 30);
btnMyLocation.setLayoutParams(layoutParams);
当我们启用 setMylocationEnabled(true)
时,地图片段上出现的当前位置的蓝色圆形图标需要在我的场景中更改。我怎样才能实现默认情况下出现车辆图标而不是蓝色图标。谢谢。
试试这个,对我有用
ImageView btnMyLocation = (ImageView) ((View) mapFragment.getView().findViewById(Integer.parseInt("1")).getParent()).findViewById(Integer.parseInt("2"));
btnMyLocation.setImageResource(R.drawable.ic_current_location);
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)
btnMyLocation.getLayoutParams();
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
layoutParams.setMargins(0, 0, 30, 30);
btnMyLocation.setLayoutParams(layoutParams);