Giter Site home page Giter Site logo

google-maps-bottomsheet's Introduction

Google Maps BottomSheet Behavior

A BottomSheetBehavior framework mirroring Google Maps

Demo

Demo

Usage

Initializing and modifying a GoogleMapsBottomSheetBehavior is the same as the BottomSheetBehavior from the support library

View bottomsheet = findViewById(R.id.bottomsheet);
GoogleMapsBottomSheetBehavior behavior = GoogleMapsBottomSheetBehavior.from(bottomsheet);
behavior.setPeekHeight(200); // in pixels
// or use the default peek height, which is different from the support library
behavior.setPeekHeight(PEEK_HEIGHT_AUTO);
behavior.setState(GoogleMapsBottomSheetBehavior.STATE_COLLAPSED);
behavior.setHideable(false);
<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/bottomsheet"
    android:background="@android:color/white"
    android:layout_gravity="bottom"
    app:behavior_hideable="true"
    app:behavior_peekHeight="100dp"
    app:layout_behavior="com.github.reline.GoogleMapsBottomSheetBehavior">
    ...
</android.support.v4.widget.NestedScrollView>

Framework features

Anchoring

Using the offset from the top of the parent view

behavior.setAnchorOffset(200); // in pixels

or set the actual height of the bottomsheet when it is anchored

app:behavior_anchorHeight="200dp"
<!-- or use the default 16:9 ratio keyline -->
app:behavior_anchorHeight="auto"
behavior.setAnchorHeight(1100); // in pixels
// or use the default 16:9 ratio keyline
behavior.setAnchorHeight(ANCHOR_HEIGHT_AUTO);
Parallax
View parallax = ...;
behavior.setParallax(parallax);
<View
    android:id="@+id/parallax"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:background="@color/colorPrimaryDark"/>

TIP: Use behavior.getAnchorOffset() to make the parallax fill the entire gap between the anchor and the top of the screen.

LayoutParams layoutParams = new LayoutParams(parallax.getMeasuredWidth(), behavior.getAnchorOffset());
parallax.setLayoutParams(layoutParams);
Custom Header/Content and Color Animations

Color animations can easily be handled by the framework if given a header and content view.

Be advised, when using a custom heading/content view a child should not be provided to the bottom sheet.

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/bottomsheet"
    android:background="@android:color/white"
    android:layout_gravity="bottom"
    app:behavior_hideable="true"
    app:behavior_peekHeight="100dp"
    app:behavior_anchorHeight="auto"
    app:behavior_header_layout="@layout/custom_header"
    app:behavior_content_layout="@layout/custom_content"
    app:behavior_anchorColor="@color/colorPrimary"
    app:behavior_collapsedColor="@android:color/white"
    app:layout_behavior="com.github.reline.GoogleMapsBottomSheetBehavior" />

Gradle

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

dependencies {
    implementation 'com.github.reline:google-maps-bottomsheet:1.0'
}

google-maps-bottomsheet's People

Contributors

reline avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.