Rapid Subscribe Android App

Rapid Subscribe Android App
Rapid Subscriber

Recent Posts

How to Create Nested Scroll view | Show / Hide Toolbar with Android WebView

How to Create Nested Scroll view | Show / Hide Toolbar with Android WebView



When we create a WebView, we want to view the website on the full screen even we don't want to see the toolbar also.

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.


 
Follow us for more posts like this, 
Subscribe to Harpreet studio on Youtube  
Like Harpreet Studio on Facebook  
Follow me on Instagram 

4 comments:

  1. Same 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.
    mytv enter code

    ReplyDelete
  2. For reasons unknown, a few organizations are on autopilot with regards to their expo advertising.amazon.commytv

    ReplyDelete
  3. Snapchat While Snapchat can be an extraordinary method for getting your promoting message out, it tends to's be a test to get found by different clients.

    ReplyDelete