SwipeRefreshLayout不显示任何刷新指示

afo*_*tad 3 xml android view fragment swiperefreshlayout

SwipeRefreshLayout在活动中显示的片段中使用了一个.刷卡确实执行了刷新,但是在我向下拉后它向右上升并且没有不确定进度的指示(动画进度条).它刚刚消失,但在完成后仍然会调用onRefresh().这是我的布局......

活动布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <FrameLayout
            android:id="@+id/content_frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

    <ListView
            android:id="@+id/left_drawer"
            android:layout_width="@dimen/nav_drawer_width"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:choiceMode="singleChoice"
            android:dividerHeight="1px"
            android:background="@color/drawer_background_gray"
            android:clipToPadding="false"/>

</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

片段布局:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

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

        <ListView
                android:id="@android:id/list"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:clipToPadding="false"/>

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

    <TextView
            android:id="@android:id/empty"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="@dimen/empty_text_size"
            android:layout_gravity="center"
            android:gravity="center"
            android:paddingTop="5dp"
            android:paddingBottom="5dp"
            android:paddingLeft="15dp"
            android:paddingRight="15dp"
            android:textColor="@color/brand_green"/>

    <ProgressBar
            android:id="@android:id/progress"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:indeterminateOnly="true"
            android:visibility="gone"
            android:layout_gravity="center"/>

</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

用于初始化Fragment布局的代码:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_list, null);
        swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container);
        swipeLayout.setOnRefreshListener(this);
        swipeLayout.setColorScheme(android.R.color.holo_blue_bright,
                android.R.color.holo_green_light,
                android.R.color.holo_orange_light,
                android.R.color.holo_red_light);
        return view;
}
Run Code Online (Sandbox Code Playgroud)

刷新时通常会有3到6秒的延迟,足以让他在观看日志时显而易见.它应该是可见的,当我使用现已弃用的ActionBar-PullToRefresh库时它工作正常.我已经尝试制作SwipeRefreshLayout片段布局的根视图,我尝试删除空文本和进度视图,但它仍然无法正常工作.

我的实际代码中还有一些步骤,我无法透露,因为它是为我的公司设计的应用程序.但它只是为许多不同的片段提供类似的基础来做类似的事情,它不应该影响任何功能.

Jes*_*tro 11

我使用了下面的方法,经过这么多尝试后,它对我没有解决方法,甚至是片段,对我有用:

<android.support.v4.widget.SwipeRefreshLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

    <ScrollView
      android:layout_width="match_parent"
      android:layout_height="match_parent">

      ** content **

    </ScrollView>

</android.support.v4.widget.SwipeRefreshLayout>
Run Code Online (Sandbox Code Playgroud)

AppCompat库:com.android.support:appcompat-v7:21.0.3.