SwipeRefreshLayout with NestedScrollView and LinearLayout

后端 未结 5 2050
迷失自我
迷失自我 2021-02-01 16:58


        
相关标签:
5条回答
  • 2021-02-01 17:15

    You need add in your code :

            recyclerView.setNestedScrollingEnabled(false)
    
    0 讨论(0)
  • 2021-02-01 17:16

    app:layout_behavior should be added to the direct child of CoordinatorLayout. and after you need to use NestedScrollView in SwipeLayout like;

    <android.support.v4.widget.SwipeRefreshLayout 
        android:id="@+id/swipe_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">
    
        <android.support.v4.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fillViewport="true">
            ...
        </android.support.v4.widget.NestedScrollView>
    
    </android.support.v4.widget.SwipeRefreshLayout>
    
    0 讨论(0)
  • 2021-02-01 17:29

    app:layout_behavior should be added to the direct child of CoordinatorLayout.

    So you should move app:layout_behavior="@string/appbar_scrolling_view_behavior" from NestedScrollView to SwipeRefreshLayout.

    <android.support.design.widget.CoordinatorLayout ...>
    
        <android.support.design.widget.AppBarLayout  ...>
            ...
        </android.support.design.widget.AppBarLayout>
    
        <android.support.v4.widget.SwipeRefreshLayout 
            android:id="@+id/swipe_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">
    
            <android.support.v4.widget.NestedScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fillViewport="true">
                ...
            </android.support.v4.widget.NestedScrollView>
    
        </android.support.v4.widget.SwipeRefreshLayout>
    
    </android.support.design.widget.CoordinatorLayout>
    
    0 讨论(0)
  • 2021-02-01 17:35

    I solved it by myself to put the SwipeRefreshLayout as the main layout and add the rest as children

    0 讨论(0)
  • 2021-02-01 17:40

    use this

    <android.support.v4.widget.SwipeRefreshLayout 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:id="@+id/swipeContainer"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    
    <android.support.design.widget.CoordinatorLayout
        ... your attribute here ... >
    
        <android.support.design.widget.AppBarLayout
            ... your attribute here ... >
    
            <android.support.design.widget.CollapsingToolbarLayout
                ... your attribute here ... >
    
                ... your element here ...
    
            </android.support.design.widget.CollapsingToolbarLayout>
    
        </android.support.design.widget.AppBarLayout>
    
        <android.support.v4.widget.NestedScrollView
            ... your attribute here ... >
    
            ... your element here ...
    
        </android.support.v4.widget.NestedScrollView>
    </android.support.design.widget.CoordinatorLayout>
    

    0 讨论(0)
提交回复
热议问题