Android Google map v2 in tab Overlapping issue, Multiple map in tab

前端 未结 3 1801
醉话见心
醉话见心 2021-01-13 17:15

I am new to android, now am working with Google maps v2, I have used tabhost to show Google map v2, In this tabhost i need to show two Google maps v2 on different tab. When

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-13 18:07

    Just use this class .......

    public class MapFragment extends SupportMapFragment {
    
        GoogleMap mapView;
        private Context context;
    
        @Override
        public void onCreate(Bundle arg0) {
                super.onCreate(arg0);
        }
    
        @Override
        public View onCreateView(LayoutInflater mInflater, ViewGroup arg1,
                        Bundle arg2) {
                View view = super.onCreateView(mInflater, arg1, arg2);
                  setMapTransparent((ViewGroup) view);
                  return view;
        }
    
        private void setMapTransparent(ViewGroup group) {
                int childCount = group.getChildCount();
                for (int i = 0; i < childCount; i++) {
                View child = group.getChildAt(i);
    
                        if (child instanceof ViewGroup) {
                            setMapTransparent((ViewGroup) child);
                        } else if (child instanceof SurfaceView) {
                            child.setBackgroundColor(0x00000000);
                        }
                    }
                }
    
        @Override
        public void onInflate(Activity arg0, AttributeSet arg1, Bundle arg2) {
                super.onInflate(arg0, arg1, arg2);
        }
    
        @Override
        public void onActivityCreated(Bundle savedInstanceState) {
                super.onActivityCreated(savedInstanceState);
                context = getActivity();
                mapView = getMap();
    
                }
    }
    

提交回复
热议问题