Stop Fragments Going Over Actionbar In Viewpager
Solution 1:
I think you correctly identified part of the problem in your comments - that CoordinatorLayout
inherits from FrameLayout
, and as such your current layout file simply tells the ViewPager
to fill the entire screen and go on top of other content (as seen in your photo).
Edit: I've realised since posting this advice below, in quotes, isn't relevant to your question as it stands. It is only important if you want to create collapsing toolbar behaviour.
To resolve it, and keep using
CoordinatorLayout
, you would need to assign a behaviour to your content, which is only possible on a layout with nested scrolling (RecyclerView
andNestedScrollView
).You could therefore try wrapping the layout file for each of your Fragments inside the
ViewPager
inside aNestedScrollView
.
Additionally, you can try adding app:layout_behavior="@string/appbar_scrolling_view_behavior"
to your ViewPager
.
Solution 2:
Since you are usigng CoOrdinatorLayout:-
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
Solution 3:
Try adding layout_below AppBarLayout to ViewPager:
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="--some id of AppBarLayout--" />
Post a Comment for "Stop Fragments Going Over Actionbar In Viewpager"