I have an app with transparent toolbar and statusbar and there is map which takes all space of the display but I need to move native controls of Google's map view under toolbar somehow
How can it be solved? For example right now I can't reset rotation (click on circle button)
We can use GoogleMap.setPadding()
Implemented this solution (portrait mode only!):
val view = binding.root
val statusBarHeight = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
view.rootWindowInsets.getInsets(WindowInsets.Type.systemBars()).top
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
@Suppress("DEPRECATION")
view.rootWindowInsets.stableInsetTop
} else {
// 24dp
resources.getDimension(R.dimen.status_bar_height).toInt()
}
var topMargin = statusBarHeight
val tv = TypedValue()
if (requireActivity().theme.resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
val actionBarHeight =
TypedValue.complexToDimensionPixelSize(tv.data, resources.displayMetrics)
topMargin += actionBarHeight
}
googleMap.setPadding(0, topMargin, 0, 0)