can't get my location and location button not show

让人想犯罪 __ 提交于 2019-12-05 17:09:30

For some reason SupportMapFragment does not show my location button (or compass icon) when its placed inside <DrawerLayout> (<- as a root view), but there is a solution:

Put the whole <DrawerLayout> in <RelativeLayout> and remove <include> and just put whole activity_maps.xml in activity_main. Also to make it look better I would recommend moving activity_maps.xml and make a fragment from it, and then instead of <include> you would have:

<fragment
    android:id="@+id/map_fragment"
    class="com.yourpackage.MapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

You will have separated logic only for map in the fragment, an all activity stuff in activity. And we all know that MainActivity tends to grow over time for many reasons ;)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!