Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
B

BGARefreshLayout-Android

> 编程语言
Open source

多种下拉刷新效果、上拉加载更多、可配置自定义头部广告位

4.3K stars0 likes0 views
WebsiteGitHub

About

多种下拉刷新效果、上拉加载更多、可配置自定义头部广告位

:running:BGARefreshLayout-Android:running:

开发者使用 BGARefreshLayout-Android 可以对各种控件实现多种下拉刷新效果、上拉加载更多以及配置自定义头部广告位

测试 BGARefreshLayout 与 Activity、Fragment、ViewPager 的各种嵌套的 Demo

常见问题-加载更多视图无法显示

1.BGARefreshLayout 的直接子控件的高度请使用 android:layout_height="0dp" 和 android:layout_weight="1"

<cn.bingoogolapple.refreshlayout.BGARefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rl_modulename_refresh"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    
    <AnyView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />
</cn.bingoogolapple.refreshlayout.BGARefreshLayout>

2.如果是在 Fragment 中使用 BGARefreshLayout

请在 onCreateView 方法中初始化 BGARefreshLayout,不要在 onActivityCreated 方法中初始化

目前已经实现了四种下拉刷新效果:

  • 新浪微博下拉刷新风格(可设置各种状态是的文本,可设置整个刷新头部的背景)
  • 慕课网下拉刷新风格(可设置其中的 logo 和颜色成自己公司的风格,可设置整个刷新头部的背景)
  • 美团下拉刷新风格(可设置其中的图片和动画成自己公司的风格,可设置整个刷新头部的背景)
  • 类似 qq 好友列表黏性下拉刷新风格(三阶贝塞尔曲线没怎么调好,刚开始下拉时效果不太好,可设置整个刷新头部的背景)

一种上拉加载更多效果

  • 新浪微博上拉加载更多(可设置背景、状态文本)

开发者也可以继承 BGARefreshViewHolder 这个抽象类,实现相应地抽象方法做出格式各样的下拉刷新效果【例如实现 handleScale(float scale, int moveYDistance) 方法,根据 scale 实现各种下拉刷新动画】和上拉加载更多特效,可参考 BGAMoocStyleRefreshViewHolder、BGANormalRefreshViewHolder、BGAStickinessRefreshViewHolder、BGAMeiTuanRefreshViewHolder 的实现方式。

目前存在的问题

  • 当配置自定义头部广告位可滚动时,内容区域和广告位还不能平滑过度。
  • 当 BGAStickyNavLayout 中嵌套 RecyclerView 或 AbsListView,并且第一页的最后一个 item 刚好在最底部时,加载更多视图会悬浮在最后一个 item 上面
  • 正在刷新或加载更多时,用户上下滑动不会让下拉刷新视图和加载更多视图跟着滑动

效果图

基本使用

1.添加 Gradle 依赖

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

2.在布局文件中添加 BGARefreshLayout

注意:内容控件的高度请使用 android:layout_height="0dp" 和 android:layout_weight="1"

<cn.bingoogolapple.refreshlayout.BGARefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rl_modulename_refresh"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    
    <AnyView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />
</cn.bingoogolapple.refreshlayout.BGARefreshLayout>

3.在 Activity 或者 Fragment 中配置 BGARefreshLayout

…

更多详细用法请查看 Wiki 或者 Demo

Demo 中使用到了我的另外三个库,欢迎大家 Star :smile:

  • Splash 界面滑动导航+自动轮播效果
  • 在 AdapterView 和 RecyclerView 中通用的 Adapter 和 ViewHolder。RecyclerView 支持 DataBinding 、多种 Item 类型、添加 Header 和 Footer
  • 类似新浪微博消息列表,带弹簧效果的左右滑动控件

作者联系方式

个人主页 邮箱 bingoogolapple.cn [email protected] 个人微信号 微信群 公众号 个人 QQ 号 QQ 群

打赏支持作者

如果您觉得 BGA 系列开源库或工具软件帮您节省了大量的开发时间,可以扫描下方的二维码打赏支持。您的支持将鼓励我继续创作,打赏后还可以加我微信免费开通一年 上帝小助手浏览器扩展/插件开发平台 的会员服务

微信 QQ 支付宝

作者项目推荐

  • 欢迎您使用我开发的第一个独立开发软件产品 上帝小助手浏览器扩展/插件开发平台

License

Copyright 2015 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.

GitHub Issues· 0 open

View all on GitHub

No open issues yet, or sync has not completed.

Highlights

  • •新浪微博下拉刷新风格(可设置各种状态是的文本,可设置整个刷新头部的背景)
  • •慕课网下拉刷新风格(可设置其中的 logo 和颜色成自己公司的风格,可设置整个刷新头部的背景)
  • •美团下拉刷新风格(可设置其中的图片和动画成自己公司的风格,可设置整个刷新头部的背景)
  • •类似 qq 好友列表黏性下拉刷新风格(三阶贝塞尔曲线没怎么调好,刚开始下拉时效果不太好,可设置整个刷新头部的背景)
  • •新浪微博上拉加载更多(可设置背景、状态文本)
  • •当配置自定义头部广告位可滚动时,内容区域和广告位还不能平滑过度。
  • •当 BGAStickyNavLayout 中嵌套 RecyclerView 或 AbsListView,并且第一页的最后一个 item 刚好在最底部时,加载更多视图会悬浮在最后一个 item 上面
  • •正在刷新或加载更多时,用户上下滑动不会让下拉刷新视图和加载更多视图跟着滑动
  • •把 maven { url 'https://jitpack.io' } 添加到 root build.gradle 的 repositories 中
  • •在 app build.gradle 中添加如下依赖,末尾的「latestVersion」指的是徽章 里的版本名称,请自行替换

> Tags

Javarefreshlayout

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言