I want to add bottom padding to the scrolling content in my WebView so that it is not hidden behind the navigation bar. I also want the navigation bar to be transparent while scrolling.
WebView implementation:
webview:
<WebView android:id="@+id/web_view" android:layout_width="0dp" android:layout_height="0dp" android:visibility="gone" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/appbar_layout" />
fragment:
binding.webView.apply { settings.javaScriptEnabled = true visible() loadDataWithBaseURL("", args.content, "text/html", "UTF-8", null) }
Attempts to add padding:
val initialPaddingBottom = binding.parishNoticeDetailsWebView.paddingBottom ViewCompat.setOnApplyWindowInsetsListener(binding.parishNoticeDetailsWebView) { view, insets -> val navigationBars = insets.getInsets(WindowInsetsCompat.Type.navigationBars()) view.updatePadding( bottom = initialPaddingBottom + navigationBars.bottom ) insets }