Skip to content

Instantly share code, notes, and snippets.

@dadino
Last active December 26, 2020 19:01
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save dadino/d0b3acba08163749ee9c to your computer and use it in GitHub Desktop.
Save dadino/d0b3acba08163749ee9c to your computer and use it in GitHub Desktop.
A CoordinatorLayout layout, with a Google Map that collapse itself. A TabLayout (inside the CollapsingToolbarLayout) provides navigation for the ViewPager, that sits just below the AppBarLayout. The FloatingActionButton is used to go to the next page in the ViewPager.
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
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="256dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="@color/primary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_collapseMode="parallax"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_collapseMode="parallax"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
/>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="@dimen/tab_layout_height"
android:layout_gravity="bottom"
android:layout_marginEnd="72dp"
android:layout_marginRight="72dp"
app:layout_collapseMode="none"
app:tabContentStart="16dp"
app:tabMode="scrollable"
app:tabSelectedTextColor="@color/black_primary_text"
app:tabTextColor="@color/black_secondary_text"/>
</android.support.design.widget.CollapsingToolbarLayout>
</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.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="8dp"
android:src="@drawable/ic_next"
android:transitionName="@string/transition_name_new_trip_fab"
app:borderWidth="0dp"
app:fabSize="mini"
app:layout_anchor="@id/tabs"
app:layout_anchorGravity="center|right|end"
/>
</android.support.design.widget.CoordinatorLayout>
@dadino
Copy link
Author

dadino commented Oct 16, 2015

device-2015-10-16-121019

This is what comes out of this layout.

@AmitCharkha
Copy link

Google map zoom control is not working.

@Reza-saeedi
Copy link

Google map touch not working :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment