Skip to content

Instantly share code, notes, and snippets.

@li2
Last active July 1, 2018 05:39
Show Gist options
  • Save li2/8f815ec42c3e40e28aac to your computer and use it in GitHub Desktop.
Save li2/8f815ec42c3e40e28aac to your computer and use it in GitHub Desktop.
解决 ViewPager 和 AppBarLayout 重叠问题. Android support AppBarLayout overlapping content. Add app:layout_behavior to ViewPager, this changes the View height to be below the AppBarLayout rather than full match_parent height. #tags: android-activity
<!-- http://stackoverflow.com/questions/30674648/android-design-support-tablayout-overlapping-content -->
<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.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways|snap" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<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" />
</android.support.design.widget.CoordinatorLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment