Open Rajansm opened 8 years ago
AppBarLayout.LayoutParams params =
(AppBarLayout.LayoutParams) this.getToolbar().getLayoutParams();
params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL
| AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
this is the programmatic way but fails ending up error!!
java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.support.design.widget.AppBarLayout$LayoutParams
This is because of android.support.design.widget.AppBarLayout placed with LinearLayout as a parent for Toolbar in this Library !!!
Required
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/navigation_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
.
.
<android.support.design.widget.AppBarLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways" />
</android.support.design.widget.AppBarLayout>
.
.
</android.support.v4.widget.DrawerLayout>
I am showing list of items in the fragment. The fragment is setup using this library. I want to hide the action bar (or Tab bar) when User scrolls down the list, just to have more space on screen.
any idea how can I achieve this?