In Google chrome and play store. the app can hide the actionbar while scrolling and allows the user to Browse conveniently. Please Help me to do like this.
I've used onTouchListener for webview it doesn't works.
mWebView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: getSupportActionBar().show(); break; case MotionEvent.ACTION_UP: getSupportActionBar().hide(); break; default: break; } return false; } });
Thanks in Advance
Hide the Status Bar on Android 4. getDecorView(); // Hide the status bar. // status bar is hidden, so hide that too if necessary. ActionBar actionBar = getActionBar();
setScrollContainer(false); Don't forget to add the webview. setOnTouchListener(...) code above to disable all scrolling in the webview.
What is the difference between the toolbar and the action bar? The most obvious difference between the two is the updated visual design of the toolbar. The toolbar no longer includes an icon on the left side and decreases some of the spacing between the action items on the right side.
You can do this without any Java code using the design library's CoordinatorLayout
and NestedScrollView
, with app:layout_scrollFlags
set on Toolbar
. Here's how you do it.
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:layout_scrollFlags="scroll|enterAlways" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> </android.support.design.widget.AppBarLayout> <android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="fill_vertical" android:fillViewport="true" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <WebView android:id="@+id/webview" android:layout_width="match_parent" android:layout_height="match_parent"/> </android.support.v4.widget.NestedScrollView> </android.support.design.widget.CoordinatorLayout>
You can play around with with different layout_scrollFlags and fitsSystemWindows behaviour once you get the hang of it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With