android - Disable toolbar scrolling when pressing on it -
i tried find same question didn't know search for. if else finds simliar question, let me know!
i've implemented toolbar design library follows:
<android.support.design.widget.appbarlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/apptheme.appbaroverlay"> <include layout="@layout/toolbar" /> <android.support.design.widget.tablayout android:id="@+id/maintablayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/colorprimary" android:minheight="?attr/actionbarsize" android:theme="@style/themeoverlay.appcompat.dark.actionbar" app:tabgravity="fill" /> </android.support.design.widget.appbarlayout>
and toolbar layout:
<android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/maintoolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:background="?attr/colorprimary" android:theme="@style/apptheme.appbaroverlay" app:layout_scrollflags="scroll|enteralways" app:popuptheme="@style/apptheme.popupoverlay" />
the appbarlayout direct child coordinatorlayout. below appbar have recyclerview correctly lets appbar collapse when scrolling up.
however i'm able press directly on appbar , move finger , way toolbar collapses though recyclerview empty. can expand again scrolling down on toolbar again. behavior doesn't happen when scrolling recyclerview is.
i hope problem understandable. i'm using version 25.1 of support library. thanks!
edit: tried solutions below. didn't change anything. down below added video show issue is. it's situation when screen not full (so no elements recyclerview goes off screen): if that's case don't want toolbar hide @ all. in other words: hide toolbar if elements recyclerview go off screen.
https://drive.google.com/file/d/0bzrw-iuz9usumurvvkrfb3dkrtq/view?usp=sharing
if more code needed side let know.
try entire project @ location: https://github.com/slidenerd/android-design-support-library-demo
the below code works me(this git project belongs slidenered. thanx him):
<android.support.v4.widget.drawerlayout 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/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="slidenerd.vivz.navigationviewdemo.fourthactivity"> <android.support.design.widget.coordinatorlayout android:id="@+id/root_coordinator" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.appbarlayout android:id="@+id/app_bar_layout" android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.design.widget.collapsingtoolbarlayout android:id="@+id/collapsing_toolbar_layout" android:layout_width="match_parent" android:layout_height="wrap_content" app:contentscrim="?attr/colorprimary" app:layout_scrollflags="scroll|enteralways"> <imageview android:layout_width="match_parent" android:layout_height="192dp" android:scaletype="centercrop" android:src="@drawable/rsz_bg_cover" app:layout_collapsemode="parallax" /> <android.support.v7.widget.toolbar android:id="@+id/app_bar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:theme="@style/themeoverlay.appcompat.dark.actionbar" app:layout_collapsemode="pin" /> </android.support.design.widget.collapsingtoolbarlayout> <android.support.design.widget.collapsingtoolbarlayout android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_scrollflags="scroll|enteralways"> <android.support.design.widget.tablayout android:id="@+id/tab_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/coloraccent" app:layout_collapsemode="pin" app:tabindicatorcolor="@color/colorprimary" app:tabselectedtextcolor="@android:color/white" app:tabtextcolor="#eee" /> </android.support.design.widget.collapsingtoolbarlayout> </android.support.design.widget.appbarlayout> <android.support.v4.view.viewpager android:id="@+id/view_pager" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> <android.support.design.widget.floatingactionbutton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|right" android:layout_margin="16dp" android:src="@drawable/ic_add_black" app:borderwidth="0dp" app:fabsize="mini" /> </android.support.design.widget.coordinatorlayout> <android.support.design.widget.navigationview android:id="@+id/navigation_drawer" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" app:menu="@menu/menu_drawer" />
Comments
Post a Comment