How to Create Nested Scroll view | Show / Hide Toolbar with Android WebView
How to Create Nested Scroll view | Show / Hide Toolbar with Android WebView
With Nested Scroll View, you can hide your toolbar when you browse a webpage and then the toolbar is shown when you again scroll to top.
To create a Nested Scroll view, Follow the Steps.
- Create a Nested Scroll view in XML.
- Add Scroll Flags in Toolbar
- Put Webview under Nested Scroll View.
Your XML File
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimaryDark"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways|snap"
app:title="">
</androidx.appcompat.widget.Toolbar>
<ProgressBar
android:id="@+id/progressBar3"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="3dp"
android:indeterminate="true"
android:scaleY="5.0" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/nestedsv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="false"
android:fitsSystemWindows="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<WebView
android:id="@+id/webviewbrowser"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Here, Your Nested Scroll View is ready. Now you can easily show/hide Toolbar while browsing a WebPage in your WebView.
Subscribe to Harpreet studio on Youtube
Like Harpreet Studio on Facebook
Follow me on Instagram
Thank you so much brother
ReplyDeleteSame as the actual name says this kind of shows either about Makeover of an individual's appearance or make a remodel of your old house.
ReplyDeletemytv enter code
For reasons unknown, a few organizations are on autopilot with regards to their expo advertising.amazon.commytv
ReplyDeleteThanks for fantastic information I was looking for this information for my mission.
ReplyDeleteplay game for relax and win get moneyy meto