Android Google 地图透明系统栏导致 UI 控件与工具栏重叠
Android Google Maps transparent system bar causes UI controls overlap the Toolbar
我想在透明系统栏下有一个Google地图。我的问题是 UI 控件(指南针和我的位置按钮)被工具栏遮挡了。我该如何解决?请注意,在地图上设置 android:fitsSystemWindows="true"
不是解决方案 - 它会阻止地图在系统栏下绘制。
我通过设置使系统栏透明:
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
我的风格。
只需在地图顶部添加一个填充。例如:
googleMap.setPadding(0, 100, 0, 0);
来自 the documentation(强调我的):
This method allows you to define a visible region on the map, to signal to the map that portions of the map around the edges may be obscured, by setting padding on each of the four edges of the map. Map functions will be adapted to the padding. For example, the zoom controls, compass, copyright notices and Google logo will be moved to fit inside the defined region, camera movements will be relative to the center of the visible region, etc.
我想在透明系统栏下有一个Google地图。我的问题是 UI 控件(指南针和我的位置按钮)被工具栏遮挡了。我该如何解决?请注意,在地图上设置 android:fitsSystemWindows="true"
不是解决方案 - 它会阻止地图在系统栏下绘制。
我通过设置使系统栏透明:
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
我的风格。
只需在地图顶部添加一个填充。例如:
googleMap.setPadding(0, 100, 0, 0);
来自 the documentation(强调我的):
This method allows you to define a visible region on the map, to signal to the map that portions of the map around the edges may be obscured, by setting padding on each of the four edges of the map. Map functions will be adapted to the padding. For example, the zoom controls, compass, copyright notices and Google logo will be moved to fit inside the defined region, camera movements will be relative to the center of the visible region, etc.