下拉關閉一個Activity:Pull Back Layout
下拉關閉一個Activity。

下載
repositories {
// ...
maven { url "https://jitpack.io" }
}
dependencies {
// ... support library ...
// ...
compile 'com.github.oxoooo:pull-back-layout:1.0.0'
}使用
You may refer to one of our apps that already using this library: mr-mantou-android
-
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>2.Wrapsooo.oxo.library.widget.PullBackLayoutaround yourImageVieworViewPager:
<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>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();
}
}項目主頁:http://www.baiduhome.net/lib/view/home/1444985332497
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!