saeedeh masjedjamei
saeedeh masjedjamei

Reputation: 117

White space on top of ViewPager in CoordinatorLayout

In the main layout, I have a coordinatorLayout and its children are appbarLayout and viewPager. In each page of the viewPager, I have a fragment, that either it has a nestedScrollview or a recyclerview. My problem is that there is a white space on top of all the fragments in each page of the viewPager.

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 
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:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
android:id="@+id/konta">

<android.support.design.widget.AppBarLayout
    android:id="@+id/smooth_app_bar_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/blue_200"
    android:minHeight="@dimen/mdSecondaryActionBarSize">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar_layout"
        android:layout_width="match_parent"
        android:layout_height="@dimen/app_bar_height"
        app:titleEnabled="false"
        app:layout_collapseMode="parallax"
        android:background="@android:color/transparent"
        app:layout_scrollFlags="scroll|snap">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="@dimen/toolbar_height"
            android:background="@android:color/transparent"
            app:layout_collapseMode="pin"
            app:layout_scrollFlags="scroll|enterAlways"
            app:navigationIcon="@drawable/ic_arrow_right" />
    </android.support.design.widget.CollapsingToolbarLayout>
    <android.support.design.widget.TabLayout
        android:layoutDirection="ltr"
        tools:targetApi="jelly_bean_mr1"
        android:id="@+id/tab_layout"
        android:layout_width="match_parent"
        android:layout_height="@dimen/tab_size"
        android:background="@android:color/transparent"
        app:tabIndicatorColor="@android:color/white" />

</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"
    android:layout_gravity="fill_vertical"
    android:fitsSystemWindows="true"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>

Upvotes: 3

Views: 689

Answers (1)

virusarthak
virusarthak

Reputation: 324

You should try this in your XML file:

   android:layout_marginStart="0dp"  

Upvotes: 1

Related Questions