How to add custom controls to MapFragment in Google Maps Android API v2?

后端 未结 5 1319
故里飘歌
故里飘歌 2021-02-01 08:38

I have SupportMapFragment and I need to add custom controls into it for changing a map type. Calling getView(), I get NoSaveStateFramelayout and I don\'t think it is a good idea

5条回答
  •  不思量自难忘°
    2021-02-01 09:31

    Use this code to add you layout above of the map

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View mapView = super.onCreateView(inflater, container, savedInstanceState);
        @SuppressLint("InflateParams")
        FrameLayout view = (FrameLayout) inflater.inflate(R.layout.fragment_map, null);
        view.addView(mapView, 0, new RelativeLayout.LayoutParams(-1, -1));
        return view;
    }
    

提交回复
热议问题