Swiperefreshlayout

实现下拉刷新 UI 模式。
最新更新 稳定版 发布候选版 Beta 版 Alpha 版
2025 年 2 月 12 日 1.1.0 - 1.2.0-beta01 -

声明依赖项

要添加对 SwipeRefreshLayout 的依赖项,您必须将 Google Maven 仓库添加到您的项目中。有关详情,请参阅Google 的 Maven 仓库

在应用或模块的 build.gradle 文件中添加所需工件的依赖项

Groovy

dependencies {
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
}

Kotlin

dependencies {
    implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
}

有关依赖项的更多信息,请参阅添加构建依赖项

反馈

您的反馈有助于改进 Jetpack。如果您发现新问题或有改进此库的建议,请告诉我们。在创建新问题之前,请查看此库中的现有问题。您可以通过点击星标按钮来支持现有问题。

创建新问题

有关详情,请参阅问题跟踪器文档

版本 1.2.0

版本 1.2.0-beta01

2025 年 2 月 12 日

androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-beta01 已发布。版本 1.2.0-beta01 包含这些提交

API 变更

  • 指定了 SwipeRefreshLayout 方法参数和返回类型的可空性 (I006d1, b/236497776)

错误修复

  • 此库现在使用类型用法的 JSpecify 空值注解。Kotlin 开发者应使用以下编译器参数来强制执行正确用法:-Xjspecify-annotations=strict(从 Kotlin 编译器 2.1.0 版本开始,这是默认设置)。(Iaf490, b/326456246)

版本 1.2.0-alpha01

2020 年 7 月 22 日

androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01 已发布。版本 1.2.0-alpha01 包含这些提交。

错误修复

  • requestDisallowInterceptTouchEvent(boolean) 现在像其他 ViewGroup 一样遵守请求。虽然强烈不建议,但可以使用 setLegacyRequestDisallowInterceptTouchEventEnabled 禁用新行为。(I968da, b/141855018)

版本 1.1.0

版本 1.1.0

2020 年 6 月 24 日

androidx.swiperefreshlayout:swiperefreshlayout:1.1.0 已发布。版本 1.1.0 包含这些提交。

1.0.0 版以来的主要变更

  • SwipeRefreshLayout 现在实现了 NestedScrollingChild3NestedScrollingParent3

版本 1.1.0-rc01

2020 年 4 月 15 日

androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-rc01 已发布,自 1.1.0-beta01 以来无任何更改。版本 1.1.0-rc01 包含这些提交。

版本 1.1.0-beta01

2020 年 3 月 4 日

androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-beta01 已发布,自 1.1.0-alpha03 以来无任何更改。版本 1.1.0-beta01 包含这些提交。

版本 1.1.0-alpha03

2019 年 10 月 9 日

androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha03 已发布。版本 1.1.0-alpha03 包含这些提交

新功能

  • 我们新增了一个样式属性 R.styleable.SwipeRefreshLayout_swipeRefreshLayoutProgressSpinnerBackgroundColor,用于设置进度指示器的背景颜色。(aosp/931124)

API 变更

  • requestDisallowInterceptTouchEvent(boolean) 现在始终传播到其父级。虽然强烈不建议,但可以使用 setLegacyRequestDisallowInterceptTouchEventEnabled 禁用新行为。(aosp/1108540)

错误修复

  • 修复了当 SwipeRefreshLayout 具有可滚动父级(例如 ViewPager2)和可滚动子级时的嵌套滚动问题。(b/138314213)

版本 1.1.0-alpha02

2019 年 7 月 2 日

androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02 已发布。此版本中包含的提交可在此处找到。

错误修复

  • 实现了 SwipeRefreshLayout 刷新状态的保存和恢复
  • 修复了当 SwipeRefreshLayout 嵌入到 RecyclerView 中时的可用性错误

版本 1.1.0-alpha01

2018 年 12 月 3 日

API 变更

  • aosp/737631: SwipeRefreshLayout 现在实现了 NestedScrollingChild3NestedScrollingParent3,从而使嵌套滚动 3 父级和子级能够通过 SwipeRefreshLayout 传递已消耗的嵌套滚动距离信息。如果开发者代码当前覆盖了 SwipeRefreshLayout.onNestedScroll(View, int, int, int, int, int),则很可能不再调用它,而应改为覆盖 SwipeRefreshLayout.onNestedScroll(View, int, int, int, int, int, int[])。同样,SwipeRefreshLayout.dispatchNestedScroll(int, int, int, int, int[], int) 很可能不再被调用,而应改为覆盖 SwipeRefreshLayout.dispatchNestedScroll(int, int, int, int, int[], int, int[])