
[英]How to make SwipeRefreshLayout work when the RecyclerView is empty
[英]Add SwipeRefreshLayout to RecyclerView when it has an empty header
如问题的答案中所述,我已将headerView添加到我的RecyclerView中: RecyclerView是否具有等效的addHeaderView?
标头是一个空视图,将被隐藏在工具栏下。
<?xml version="1.0" encoding="utf-8"?>
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" />
问题是SwipeRefreshLayout的位置。 它将从工具栏下的标题开始,因此它部分隐藏在工具栏下。
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="com.test.android.client.fragment.MyFragment">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" >
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.SwipeRefreshLayout>
我怎么解决这个问题?
我发现setProgressViewOffset方法是一种解决方法
但是我仍然无法弄清楚如何获得默认的开始和结束位置。 (将在方法中传递的参数)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.