2017-02-15 93 views
0

因此,我正在制作基于GoogleMaps的游戏。因为我想制作一部相机,所以我需要整个Google地图的像素大小。Android/Google Maps API - 计算完整地图的像素宽度和高度

继承人我的意思:

Sizes i actually mean

我已经尝试过:

// pre generated by android studios 
    // Obtain the SupportMapFragment and get notified when the map is ready to be used. 
    mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); 

    mapFragment.getMapAsync(this); 


    int width = mapFragment.getView().getMeasuredWidth(); 

    int height = mapFragment.getView().getMeasuredHeight(); 


    String widthAndHeight = width+" "+height; 

但它只返回null。片段有什么问题?任何其他方式来计算谷歌地图的全尺寸?或者这只是返回当前显示的地图部分的大小?

+0

在http://stackoverflow.com/questions/6939002/if-i-call-getmeasuredwidth-or-getwidth-for看看-layout-in-onresume-they-return-0 – antonio

+0

帖子回答:D,比我要除了它。 – genaray

回答