添加SwipeRefreshLayout到RecyclerView当它具有一个空的头 [英] Add SwipeRefreshLayout to RecyclerView when it has an empty header
问题描述
我添加了一个headerView我RecyclerView在这个问题的答案说明:<一href=\"http://stackoverflow.com/questions/26530685/is-there-an-addheaderview-equivalent-for-recyclerview\">Is有一个addHeaderView相当于RecyclerView?
I have added a headerView to my RecyclerView as described in the answer of this question: Is there an addHeaderView equivalent for RecyclerView?
标题是将工具栏下面隐藏空视图。
The header is an empty view which will be hidden under toolBar.
<?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的地方。它将从标题是工具栏下启动,所以它的工具栏下的部分隐藏。
The problem is the place of SwipeRefreshLayout. It will be started from Header which is under Toolbar, so it partially hidden under Toolbar.
<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>
我该如何解决这个问题呢?
How can I solve this problem?
推荐答案
我发现setProgressViewOffset方法作为一种解决方法
I found setProgressViewOffset method as a workaround
<一个href=\"https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html#setProgressViewOffset(boolean\" rel=\"nofollow\">https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html#setProgressViewOffset(boolean, INT,INT)
https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html#setProgressViewOffset(boolean, int, int)
不过还是我无法弄清楚我如何能得到默认的开始和结束现在的位置。 (参数将在该方法被传递)
But still I am not able to figure out how can I get default start and end postion. (parameter which will be passed in the method)
这篇关于添加SwipeRefreshLayout到RecyclerView当它具有一个空的头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!