How to add bottom padding for the navigation bar in a WebView (Android Components)?


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 }
0
Mar 17 at 11:20 AM
User AvatarStanisław Olszak
#android#android-15#android-components

No answer found for this question yet.