GithubHelp home page GithubHelp logo

albersmc / bottomsheet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from soarcn/bottomsheet

0.0 1.0 0.0 736 KB

One way to present a set of actions to a user is with bottom sheets, a sheet of paper that slides up from the bottom edge of the screen. Bottom sheets offer flexibility in the display of clear and simple actions that do not need explanation.

Java 100.00%

bottomsheet's Introduction

BottomSheet

Build Status Android Arsenal

One way to present a set of actions to a user is with bottom sheets, a sheet of paper that slides up from the bottom edge of the screen. Bottom sheets offer flexibility in the display of clear and simple actions that do not need explanation.

https://www.google.com/design/spec/components/bottom-sheets.html

This library works on android 2.1+

Sample Sample Sample Sample Sample Sample

How to use this library

  • Download this library, import to your IDE (eclipse...) as a library project.
  • Using Gradle
    compile 'com.cocosw:bottomsheet:1.+@aar'
  • Using Maven
<dependency>
    <groupId>com.cocosw</groupId>
    <artifactId>bottomsheet</artifactId>
    <version>1.x</version>
    <type>apklib</type>
</dependency>
  • Compile you project with android sdk v21+

API

  • Define actions in menu xml (only id/title/icon attribution been supported right now)
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/share" android:title="@string/share" android:icon="@drawable/perm_group_messages"/>
    <item android:id="@+id/upload" android:title="@string/upload" android:icon="@drawable/perm_group_system_clock"/>
    <item android:id="@+id/call" android:title="@string/call" android:icon="@drawable/perm_group_phone_calls"/>
    <divider/>
    <item android:id="@+id/help" android:title="@string/help" android:icon="@drawable/perm_group_system_tools"/>
</menu>
  • Call it just like you calling a dialog
new BottomSheet.Builder(this).title("title").sheet(R.menu.list).listener(new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        switch (which) {
                            case R.id.help:
                                q.toast("Help me!");
                                break;
                        }
                    }
                }).show();
  • You can also add action items in builder.

Style

  • Invoke darkTheme() to show build-in dark theme
  • Or define your style in your application, and call bottomsheet by using new BottomSheet.Builder(this,R.style.BottomSheet_StyleDialog)....
    <style name="BottomSheet.StyleDialog" parent="BottomSheet.Dialog">
        <item name="android:backgroundDimAmount">0.5</item>
        <item name="android:windowAnimationStyle">@style/BottomSheet.Animation</item>
        <item name="android:textColorPrimary">#DDffffff</item>
        <item name="android:textColorSecondary">#8Affffff</item>
        <item name="android:textColorHint">#42ffffff</item>
        <item name="bs_dialogBackground">@color/abc_search_url_text_normal</item>
        <item name="bs_dividerColor">@color/abc_search_url_text_pressed</item>
        <item name="bs_numColumns">4</item>
        <item name="bs_listStyle">@style/BottomSheet.StyleList</item>
    </style>
  • Or set bottomesheet style in your activity theme
    <style name="StyleTheme" parent="Theme.AppCompat">
        <item name="bottomSheetStyle">@style/BottomSheet.StyleDialog</item>
    </style>

Contribute

  • Feel free to fork it

About me

I'm Kai, an 32 years old android developer based in Sydney. I'm looking for a job right now, contact me if you think I can be of service to you. Thanks!

License

Copyright 2011, 2015 Kai Liao

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

bottomsheet's People

Contributors

anatoly-lp avatar kennyc1012 avatar soarcn avatar toshmeston avatar vovkab avatar

Watchers

 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.