NestedScrollView中的SwipeRefreshLayout无法正常工作

时间:2018-09-25 17:23:35

标签: android xml swiperefreshlayout android-nestedscrollview

我学会了使用SwipeRefreshLayout,但是在此小部件中,动态动画无法更新,因此我无法理解为什么会发生这种情况,我的代码与我对其他对象使用的代码相同,希望找到解决我的问题的答案。

<android.support.v4.widget.NestedScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="@dimen/popup_actions_height"
    android:fillViewport="true"
    android:overScrollMode="ifContentScrolls"
    android:theme="@style/AppTheme.Dark"
    tools:context=".ui.fragments.actions.MiniChatFragment">

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

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="vertical"
            tools:visibility="visible">

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

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/recycler"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:clipToPadding="false"
                    android:nestedScrollingEnabled="false"
                    android:overScrollMode="ifContentScrolls"
                    android:scrollbarStyle="outsideOverlay"
                    android:scrollbars="vertical"
                    app:layout_behavior="@string/appbar_scrolling_view_behavior"
                    tools:itemCount="4"
                    tools:layoutManager="android.support.v7.widget.LinearLayoutManager"
                    tools:listitem="@layout/item_mini_chat_text"
                    tools:spanCount="1" />

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

        </LinearLayout>

    </RelativeLayout>

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

这是我用于Swiprefreshlayout的代码

private void setupSwipeRefresh() {
        mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(
                getResources().getColor(R.color.colorCardLight));
        mSwipeRefreshLayout.setColorSchemeResources(R.color.colorAccent);
        mSwipeRefreshLayout.setOnRefreshListener(
                new SwipeRefreshLayout.OnRefreshListener() {
                    @Override
                    public void onRefresh() {
                        loadDataApi(mMessageId);
                        mSwipeRefreshLayout.setRefreshing(false);
                    }
                });
    }

0 个答案:

没有答案