Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why would my ViewPager go out of bound inside a CoordinatorLayout?

For some reasons I can't grasp, the Viewpager in the image below overflows by the size of the menu. I'm probably not picturing something but I can't see what.

As you can see the ViewPager which is selected goes out of bounds

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="160dp"
    android:paddingTop="@dimen/appbar_padding_top"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="wrap_content"
        android:layout_height="160dp"
        >
    </android.support.v7.widget.Toolbar>

</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
    android:id="@+id/container"
    android:layout_width="match_parent"

    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    />

like image 752
Gurg Hackpof Avatar asked Oct 30 '22 14:10

Gurg Hackpof


1 Answers

Your ViewPager goes out of bound because of the flag

app:layout_behavior="@string/appbar_scrolling_view_behavior"

that you've set in its XML layout. This us mainly used when you want to be able to use Google's Material Design scroll effects. If you're not interested in handling scrolls with the CoordinatorLayout, you can just delete that line.

like image 123
Mohammed Aouf Zouag Avatar answered Nov 15 '22 07:11

Mohammed Aouf Zouag