GithubHelp home page GithubHelp logo

aaaliua / pull-back-layout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oxoooo/pull-back-layout

0.0 2.0 0.0 414 KB

Pull down to finish an Activity.

Home Page: http://www.oxo.ooo

License: MIT License

Java 100.00%

pull-back-layout's Introduction

Pull Back Layout

Pull down to finish an Activity.

Download

repositories {
    // ...
    maven { url "https://jitpack.io" }
}

dependencies {
    // ... support library ...
    // ...
    compile 'com.github.oxoooo:pull-back-layout:1.0.0'
}

Usage

You may refer to one of our apps that already using this library: mr-mantou-android

  1. Make your Activity translucent by adding these two lines to your theme:
<style name="AppTheme" ...>
    <!-- ... -->

    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowIsTranslucent">true</item>

    <!-- also translucent system ui -- suggested but not required -->
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
</style>
  1. Wraps ooo.oxo.library.widget.PullBackLayout around your ImageView or ViewPager:
<ooo.oxo.library.widget.PullBackLayout
    android:id="@+id/puller"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</ooo.oxo.library.widget.PullBackLayout>
  1. Set a callback:
public class ViewerActivity extends AppCompatActivity implements PullBackLayout.Callback {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        /* ... */
        puller.setCallback(this);
    }

    @Override
    public void onPullStart() {
        // fade out Action Bar ...
        // show Status Bar ...
    }

    @Override
    public void onPull(float progress) {
        // set the opacity of the window's background
    }

    @Override
    public void onPullCancel() {
        // fade in Action Bar
    }

    @Override
    public void onPullComplete() {
        supportFinishAfterTransition();
    }

}

License

MIT License

pull-back-layout's People

Contributors

xingrz avatar

Watchers

James Cloos avatar lllllttttt 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.