android - How to hide Only Tablayout when scroll in Fragment's GridView? -
i need hide tablayout , filter layout when scroll in fragment's gridview. here tried hide tablayout refers link not working. how hide 2 layouts when scroll.
<?xml version="1.0" encoding="utf-8"?> <relativelayout 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/ll_main_container" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="false" android:orientation="vertical"> <android.support.design.widget.coordinatorlayout android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.appbarlayout android:id="@+id/id_appbar" android:layout_width="match_parent" android:layout_height="wrap_content"> <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_discover" style="@style/apptablayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:elevation="6dp" android:minheight="?attr/actionbarsize" app:tabtextappearance="@style/apptabtextappearance" app:layout_scrollflags="scroll|enteralways"/> </android.support.design.widget.collapsingtoolbarlayout> </android.support.design.widget.appbarlayout> <android.support.v4.view.viewpager android:id="@+id/view_pager_discover" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> </android.support.design.widget.coordinatorlayout> </relativelayout>
it seems gridview's onscrolllistener
can not dx
, dy
. gridview's setonscrollchangelistener
can requires api level 23.
i suggest use recyclerview
gridlayoutmanager
instead of gridview
, easy use.
mrecyclerview.addonscrolllistener(new recyclerview.onscrolllistener() { @override public void onscrolled(recyclerview recyclerview, int dx, int dy) { if (dy < 0) { // hide layout here } } @override public void onscrollstatechanged(recyclerview recyclerview, int newstate) { super.onscrollstatechanged(recyclerview, newstate); } });
Comments
Post a Comment