All Projects → bingoogolapple → Bgaswipebacklayout Android

bingoogolapple / Bgaswipebacklayout Android

Android Activity 滑动返回。支持微信滑动返回样式、横屏滑动返回、全屏滑动返回

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Bgaswipebacklayout Android

Smartswipe
An android library to make swipe more easier and more powerful. Android各种侧滑,有这一个就够了
Stars: ✭ 1,911 (-15.1%)
Mutual labels:  swipeback, swipebacklayout
Drag Select Recyclerview
👇 Easy Google Photos style multi-selection for RecyclerViews, powered by Kotlin and AndroidX.
Stars: ✭ 1,818 (-19.24%)
Mutual labels:  androidx
LiveDataBus
基于LiveData实现的一款不用反注册,不会内存泄露的轻量级消息总线框架,支持订阅普通事件消息和粘性事件
Stars: ✭ 17 (-99.24%)
Mutual labels:  androidx
Jetpack Mvvm Best Practice
是 难得一见 的 Jetpack MVVM 最佳实践!在 以简驭繁 的代码中,对 视图控制器 乃至 标准化开发模式 形成正确、深入的理解!
Stars: ✭ 6,950 (+208.75%)
Mutual labels:  androidx
Shapeofview
Give a custom shape to any android view, Material Design 2 ready
Stars: ✭ 2,977 (+32.25%)
Mutual labels:  androidx
Fragmentation
[DEPRECATED] A powerful library that manage Fragment for Android
Stars: ✭ 9,713 (+331.5%)
Mutual labels:  swipeback
WorkManagerNotification
This example shows how to set notification for a specific date and time with WorkManager
Stars: ✭ 91 (-95.96%)
Mutual labels:  androidx
Bgaphotopicker Android
Android 图片选择、预览、九宫格图片控件、拖拽排序九宫格图片控件
Stars: ✭ 2,131 (-5.33%)
Mutual labels:  androidx
Swipeback
SwipeBack is an android library that can finish a activity by using gesture.
Stars: ✭ 1,717 (-23.72%)
Mutual labels:  swipeback
Coil
Image loading for Android backed by Kotlin Coroutines.
Stars: ✭ 7,469 (+231.81%)
Mutual labels:  androidx
Android Skin Support
Android-skin-support is an easy dynamic skin framework to use for Android, Only one line of code to integrate it. Android 换肤框架, 极低的学习成本, 极好的用户体验. "一行"代码就可以实现换肤, 你值得拥有!!!
Stars: ✭ 5,706 (+153.49%)
Mutual labels:  androidx
Material Dialogs
😍 A beautiful, fluid, and extensible dialogs API for Kotlin & Android.
Stars: ✭ 19,118 (+749.31%)
Mutual labels:  androidx
Xbanner
🔥【图片轮播】支持图片无限轮播,支持AndroidX、自定义指示点、显示提示文字、切换动画、自定义布局,一屏显示多个等功能
Stars: ✭ 1,734 (-22.97%)
Mutual labels:  androidx
modern-android
Modern Android Project Skeleton
Stars: ✭ 17 (-99.24%)
Mutual labels:  androidx
Android Zblibrary
🔥Android MVP 快速开发框架,做国内 「示例最全面」「注释最详细」「使用最简单」「代码最严谨」的 Android 开源 UI 框架。 🔥An Android MVP Framework with many demos, detailed documents, simple usages and strict codes.
Stars: ✭ 5,000 (+122.12%)
Mutual labels:  swipeback
recast
🦸‍♂️ Recast migrates your old extensions to AndroidX, making them compatible with the latest version of Kodular.
Stars: ✭ 13 (-99.42%)
Mutual labels:  androidx
Androidutilcode
AndroidUtilCode 🔥 is a powerful & easy to use library for Android. This library encapsulates the functions that commonly used in Android development which have complete demo and unit test. By using it's encapsulated APIs, you can greatly improve the development efficiency. The program mainly consists of two modules which is utilcode, which is commonly used in development, and subutil which is rarely used in development, but the utils can be beneficial to simplify the main module. 🔥
Stars: ✭ 30,239 (+1243.36%)
Mutual labels:  androidx
Aesthetic
[DEPRECATED]
Stars: ✭ 2,044 (-9.2%)
Mutual labels:  androidx
Expansionpanel
Android - Expansion panels contain creation flows and allow lightweight editing of an element.
Stars: ✭ 1,984 (-11.86%)
Mutual labels:  androidx
Banner
🔥🔥🔥Banner 2.0 来了!Android广告图片轮播控件,内部基于ViewPager2实现,Indicator和UI都可以自定义。
Stars: ✭ 11,682 (+418.97%)
Mutual labels:  androidx

🏃BGASwipeBackLayout-Android🏃

强烈建议与 StatusBarUtil 结合着一起使用

常见问题与反馈

1.使用透明主题时,滑动返回看见了 Launcher

保证栈底 Activity 的主题是不透明的。例如 demo 中的首个 Activity 是 SplashActivity,进入主界面后 SplashActivity 就销毁了,此时 MainActivity 就是栈底 Activity,需保证 MainActivity 的主题不透明

2.使用非透明主题时,滑动返回结束时立即触摸界面应用程序崩溃

把该崩溃界面里比较特殊的 View 的 class 添加到集合中作为「BGASwipeBackHelper.init」的第2个参数,例如地图控件。目前在库中已经添加了 WebView 和 SurfaceView,不用再次添加这两个了

功能介绍

  • 通过修改 support-v4 包中 SlidingPaneLayout 的源码来实现滑动返回布局
  • 支持非透明主题滑动返回,不影响 Activity 生命周期
  • 动态设置滑动返回是否可用
  • 动态设置是否仅仅跟踪左侧边缘的滑动返回
  • 动态设置是否是微信滑动返回样式
  • 动态设置是否显示滑动返回的阴影效果
  • 支持全屏、横屏和竖屏

效果图与示例 apk

普通滑动返回样式 微信滑动返回样式
BGASwipeBackLayoutDemo BGASwipeBackLayoutDemo-WeChat
配合滑动删除列表一起使用 配合 RecycerView 一起使用
bgaswipebacklayout-swipe-delete bgaswipebacklayout-recycler-index

点击下载 BGASwipeBackLayoutDemo.apk 或扫描下面的二维码安装

BGASwipeBackLayoutDemo apk 文件二维码

1.添加 Gradle 依赖

  • maven { url 'https://jitpack.io' } 添加到 root build.gradle 的 repositories 中
  • 在 app build.gradle 中添加如下依赖,末尾的「latestVersion」指的是徽章 里的版本名称,请自行替换
implementation 'com.github.bingoogolapple:BGASwipeBackLayout-Android:latestVersion'
// 换成己工程里依赖的 support-v4 的版本
implementation 'androidx.legacy:legacy-support-v4:1.0.0'

2.必须在 Application 的 onCreate 方法中执行 BGASwipeBackHelper.init 来初始化滑动返回

public class App extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        /**
         * 必须在 Application 的 onCreate 方法中执行 BGASwipeBackHelper.init 来初始化滑动返回
         * 第一个参数:应用程序上下文
         * 第二个参数:如果发现滑动返回后立即触摸界面时应用崩溃,请把该界面里比较特殊的 View 的 class 添加到该集合中,目前在库中已经添加了 WebView 和 SurfaceView
         */
        BGASwipeBackHelper.init(this, null);
    }
}

3.将下面的代码拷贝到你自己的 BaseActivity 中,建议参考 demo 里的这个 BaseActivity 来设置界面跳转动画

public abstract class BaseActivity extends AppCompatActivity implements BGASwipeBackHelper.Delegate {
    protected BGASwipeBackHelper mSwipeBackHelper;
    protected Toolbar mToolbar;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        // 「必须在 Application 的 onCreate 方法中执行 BGASwipeBackHelper.init 来初始化滑动返回」
        // 在 super.onCreate(savedInstanceState) 之前调用该方法
        initSwipeBackFinish();
        super.onCreate(savedInstanceState);
    }

    /**
     * 初始化滑动返回。在 super.onCreate(savedInstanceState) 之前调用该方法
     */
    private void initSwipeBackFinish() {
        mSwipeBackHelper = new BGASwipeBackHelper(this, this);

        // 「必须在 Application 的 onCreate 方法中执行 BGASwipeBackHelper.init 来初始化滑动返回」
        // 下面几项可以不配置,这里只是为了讲述接口用法。

        // 设置滑动返回是否可用。默认值为 true
        mSwipeBackHelper.setSwipeBackEnable(true);
        // 设置是否仅仅跟踪左侧边缘的滑动返回。默认值为 true
        mSwipeBackHelper.setIsOnlyTrackingLeftEdge(true);
        // 设置是否是微信滑动返回样式。默认值为 true
        mSwipeBackHelper.setIsWeChatStyle(true);
        // 设置阴影资源 id。默认值为 R.drawable.bga_sbl_shadow
        mSwipeBackHelper.setShadowResId(R.drawable.bga_sbl_shadow);
        // 设置是否显示滑动返回的阴影效果。默认值为 true
        mSwipeBackHelper.setIsNeedShowShadow(true);
        // 设置阴影区域的透明度是否根据滑动的距离渐变。默认值为 true
        mSwipeBackHelper.setIsShadowAlphaGradient(true);
        // 设置触发释放后自动滑动返回的阈值,默认值为 0.3f
        mSwipeBackHelper.setSwipeBackThreshold(0.3f);
        // 设置底部导航条是否悬浮在内容上,默认值为 false
        mSwipeBackHelper.setIsNavigationBarOverlap(false);
    }

    /**
     * 是否支持滑动返回。这里在父类中默认返回 true 来支持滑动返回,如果某个界面不想支持滑动返回则重写该方法返回 false 即可
     *
     * @return
     */
    @Override
    public boolean isSupportSwipeBack() {
        return true;
    }

    /**
     * 正在滑动返回
     *
     * @param slideOffset 从 0 到 1
     */
    @Override
    public void onSwipeBackLayoutSlide(float slideOffset) {
    }

    /**
     * 没达到滑动返回的阈值,取消滑动返回动作,回到默认状态
     */
    @Override
    public void onSwipeBackLayoutCancel() {
    }

    /**
     * 滑动返回执行完毕,销毁当前 Activity
     */
    @Override
    public void onSwipeBackLayoutExecuted() {
        mSwipeBackHelper.swipeBackward();
    }

    @Override
    public void onBackPressed() {
        // 正在滑动返回的时候取消返回按钮事件
        if (mSwipeBackHelper.isSliding()) {
            return;
        }
        mSwipeBackHelper.backward();
    }
}

4.强烈强烈强烈建议把 BGASwipeBackHelper 里的每个方法的注释看一遍,只看注释就好

demo 中用到的第三方库

  • StatusBarUtil A util for setting status bar style on Android App
  • BGABaseAdapter-Android 在 AdapterView 和 RecyclerView 中通用的 Adapter 和 ViewHolder。RecyclerView 支持 DataBinding 、多种 Item 类型、添加 Header 和 Footer。RecyclerView 竖直方向通用分割线 BGADivider,吸顶分类
  • BGAProgressBar-Android 带百分比数字的水平、圆形进度条
  • BGARefreshLayout-Android 多种下拉刷新效果、上拉加载更多、可配置自定义头部广告位
  • BGASwipeItemLayout-Android 类似 iOS 带弹簧效果的左右滑动控件,可作为 AbsListView 和 RecyclerView 的 item
  • 谷爹的 support 包

代码是最好的老师,更多详细用法请查看 demo🐾

关于我

个人主页 邮箱 BGA 系列开源库 QQ 群 GitHub 喵(专注于 GitHub 等一切与程序员有关的内容)
bingoogolapple.cn [email protected] BGA_CODE_CLUB GitHub喵

打赏支持

如果您觉得 BGA 系列开源库帮你节省了大量的开发时间,请扫描下方的二维码随意打赏,要是能打赏个 10.24 🐵就太👍了。您的支持将鼓励我继续创作:octocat:

如果您目前正打算购买通往墙外的梯子,可以使用我的邀请码「YFQ9Q3B」购买 Lantern,双方都赠送三个月的专业版使用时间🍻

License

Copyright (C) 2012 The Android Open Source Project
Copyright 2016 bingoogolapple

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].