Add SwipeRefreshLayout to RecyclerView when it has an empty header

夙愿已清 提交于 2019-12-11 06:16:53

问题


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" />

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?


回答1:


I found setProgressViewOffset method as a workaround

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)



来源:https://stackoverflow.com/questions/29184409/add-swiperefreshlayout-to-recyclerview-when-it-has-an-empty-header

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!