第一步:首先在应用或模块的
build.gradle
文件中添加所需工件的依赖项
dependencies {
implementation “androidx.swiperefreshlayout:swiperefreshlayout:1.0.0”
}
<?xml version="1.0" encoding="utf-8"?>第二步:编写布局文件
<LinearLayout
xmlns:android=“http://schemas.android.com/apk/res/android”
xmlns:app=“http://schemas.android.com/apk/res-auto”
xmlns:tools=“http://schemas.android.com/tools”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
tools:context=“.MainActivity”>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:layout_width=“match_parent”
android:layout_height=“match_parent”>
android:layout_width=“match_parent”
android:layout_height=“match_parent”/>
</androidx.swiperefr