Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

刷新动画太快突兀并且MaterialHeader不刷新会冒出一点阴影 #924

Closed
liangjingkanji opened this issue Jun 2, 2019 · 4 comments

Comments

@liangjingkanji
Copy link

MaterialHeader比官方的Swipe拖动距离多的多, 很难拖下来

@AigioL
Copy link

AigioL commented Jun 5, 2019

建议加入新的api
setHeaderTrigger(float dpValue)
setHeaderTrigger(int pxValue)
setFooterTrigger(float dpValue)
setFooterTrigger(int pxValue)

MaterialHeader中加入与SwipeRefreshLayout相同的方法
setProgressBackgroundColorSchemeColor
setProgressBackgroundColorSchemeResource


触发下拉刷新的距离

本库触发下拉刷新的距离就是 Header 的高度乘以比率:HeaderHeight*HeaderTriggerRate,下拉的距离超过这个值释放时就可以触发刷新事件,否则回弹到原始状态。

HeaderTriggerRate 默认是 1,改成0.5,那么再下拉到一半的时候就可以刷新了
改变这个距离就是 setHeaderHeight setHeaderHeightPx
footer 类推

相关方法

name format description
setHeaderHeight dimension Header的标准高度(px/dp 两个版本)
setFooterHeight dimension Footer的标准高度(px/dp 两个版本)
setHeaderTriggerRate float Header触发刷新距离 与 HeaderHeight 的比率(默认1)
setFooterTriggerRate float Footer触发加载距离 与 FooterHeight 的比率(默认1)

相关属性

name format description
srlHeaderHeight dimension Header的标准高度(dp)
srlFooterHeight dimension Footer的标准高度(dp)
srlHeaderTriggerRate float Header触发刷新距离 与 HeaderHeight 的比率(默认1)
srlFooterTriggerRate float Footer触发加载距离 与 FooterHeight 的比率(默认1)

Originally posted by @scwang90 in #71 (comment)

@AigioL
Copy link

AigioL commented Jun 5, 2019

这样好像可以

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/swipeRefreshLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.scwang.smartrefresh.layout.SmartRefreshLayout
        android:id="@+id/refreshLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:srlEnableLoadMore="true"
        app:srlEnableRefresh="false">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:listitem="@layout/c_select_item" />

        <com.scwang.smartrefresh.layout.footer.ClassicsFooter
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </com.scwang.smartrefresh.layout.SmartRefreshLayout>

</android.support.v4.widget.SwipeRefreshLayout>

@liangjingkanji
Copy link
Author

这样好像可以

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/swipeRefreshLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.scwang.smartrefresh.layout.SmartRefreshLayout
        android:id="@+id/refreshLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:srlEnableLoadMore="true"
        app:srlEnableRefresh="false">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:listitem="@layout/c_select_item" />

        <com.scwang.smartrefresh.layout.footer.ClassicsFooter
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </com.scwang.smartrefresh.layout.SmartRefreshLayout>

</android.support.v4.widget.SwipeRefreshLayout>

无论是Classic或者MD我觉得autoRefresh的动画不够平滑(类似动画插值器不合理), 加速度太快. 然后MD的下拉距离太长.
谢谢你的答案了, 我试试修改源码的下拉动画的插值器

@q232916067
Copy link

#782 解决了这个问题了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants