android - Viewpager not appearing when using CollapsingToolbarLayout -
i've been playing around design support library , have come across little problem hope can me out with.
i'm using collapsingtoolbar contain imageview collapses in parralax. in collapsingtoolbar, alse have tablayout supposed scroll viewpager. issue viewpager doesn't appear. issue seems arise when set viewpager layout_height match_parent or wrap_content. if set 600dp, problem gone view ends being fixed length isn't nice.
any grealty appreciated!
here's xml
<android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true"> <android.support.design.widget.appbarlayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="@dimen/detail_backdrop_height" android:theme="@style/themeoverlay.appcompat.dark.actionbar" android:fitssystemwindows="true" > <android.support.design.widget.collapsingtoolbarlayout android:id="@+id/collapsing_toolbar" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_scrollflags="scroll|exituntilcollapsed" android:fitssystemwindows="true" app:contentscrim="?attr/colorprimary" > <imageview android:id="@+id/backdrop" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" app:layout_collapsemode="parallax" android:src="@drawable/stock_image"/> <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" app:popuptheme="@style/themeoverlay.appcompat.light" android:layout_gravity="top" /> <android.support.design.widget.tablayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom"/> </android.support.design.widget.collapsingtoolbarlayout> </android.support.design.widget.appbarlayout> <android.support.v4.widget.nestedscrollview android:layout_width="match_parent" android:layout_height="match_parent"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <android.support.v4.view.viewpager android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> </linearlayout> </android.support.v4.widget.nestedscrollview> </android.support.design.widget.coordinatorlayout>
you should remove nestedscrollview
, linearlayout
levels between coordinatorlayout
, viewpager
:
<android.support.design.widget.coordinatorlayout> <android.support.design.widget.appbarlayout> ... </android.support.design.widget.appbarlayout> <android.support.v4.view.viewpager android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> </android.support.design.widget.coordinatorlayout>
the view app:layout_behavior="@string/appbar_scrolling_view_behavior
must direct child of coordinatorlayout
positioned correctly in relation appbarlayout
.
Comments
Post a Comment