SwipeRefreshLayout 图标不显示,但回调有效

SwipeRefreshLayout icon does not show but callback works

我有一个简单的布局:

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/swiperefresh"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <FrameLayout
        android:id="@+id/result_list_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
    >

        <include
            android:id="@+id/result_list"
            layout="@layout/result_list"/>

        <include layout="@layout/loading_animated_house"/>


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

当第一个 include 可见而第二个消失时,一切都很好。

当第一个 include 消失而第二个可见时,我看不到加载图像。

在刷新之前拉动(加载图像的)超快速闪烁,但实际上 运行 在调用回调时执行了该操作。

任何线索都会有帮助,谢谢!

可以使用下面的代码,<include android:id="@+id/result_list" android:layout_width="match_parent" android:layout_height="match_parent" layout="@layout/result_list"/>

在尝试了一些场景后,我注意到:

1) onInterceptTouchEvent 永远不会 returns true 并且 mIsBeingDragged 永远不会真正设置为 true,因此以后 onTouchEvent moveSpinner 永远不会被调用。

2) onTouchEventMotionEvent.ACTION_UP 被调用,然后调用 finishSpinner,这就是我得到回调的原因。

3) 在我对响应或错误执行网络调用后,我调用 swiperefresh.setRefreshing(false); 这就是为什么我最后得到闪烁 (startScaleDownAnimation) 的原因。

确定您需要一个可触摸的 child 来开始拖动,

解决方案可能是简单地设置 FrameLayout 可点击:

    <FrameLayout
    android:id="@+id/result_list_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clickable="true"
>