Skip to content

Instantly share code, notes, and snippets.

@davidliu
Last active March 31, 2019 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidliu/75af6d19d526928bfe85c949ccd31440 to your computer and use it in GitHub Desktop.
Save davidliu/75af6d19d526928bfe85c949ccd31440 to your computer and use it in GitHub Desktop.
Example of taking advantage of app bar layout behavior for header scrolling with anything.
<?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"
android:layout_height="match_parent"
android:layout_width="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/profile_top_section"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#F00"
app:layout_scrollFlags="scroll">
<!-- User Data -->
<View android:layout_width="match_parent" android:layout_height="200dp"></View>
</RelativeLayout>
<android.support.design.widget.TabLayout
android:id="@+id/profile_tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00F"
app:layout_scrollFlags="scroll"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/profile_view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0F0"
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