scwang90 / SmartRefreshLayout

🔥下拉刷新、上拉加载、二级刷新、淘宝二楼、RefreshLayout、OverScroll,Android智能下拉刷新框架,支持越界回弹、越界拖动,具有极强的扩展性,集成了几十种炫酷的Header和 Footer。
https://segmentfault.com/a/1190000010066071
Apache License 2.0
24.96k stars 4.96k forks source link

SmartRefreshLayout 嵌套CoordinatorLayout NestedScrollView RecyclerView实现滑动置顶,加载更多遇到加载更多时tab被划出屏幕 #948

Closed liuhaifang closed 5 years ago

liuhaifang commented 5 years ago

SmartRefreshLayout 嵌套CoordinatorLayout NestedScrollView RecyclerView实现滑动置顶,加载更多遇到加载更多时tab被划出屏幕

本来要置顶的tab被划出屏幕,完整页面代码如下: <?xml version="1.0" encoding="utf-8"?> <com.scwang.smartrefresh.layout.SmartRefreshLayout 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/refreshLayout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity">

<android.support.design.widget.CoordinatorLayout

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <!-- android:fitsSystemWindow = "true" 表示整个布局展示是整个屏幕出去状态栏,标题栏和导航栏剩下的区域-->
    <android.support.design.widget.AppBarLayout
        android:id="@+id/layout_appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <!--
         app:expandedTitleMarginStart="10dp"
        设置扩张时候(还没有收缩时)title离屏幕左边的距离

         app:contentScrim="?attr/colorPrimary"
        设置当完全CollapsingToolbarLayout折叠(收缩)后的背景颜色
        -->
        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/ctb"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/white"
            android:fitsSystemWindows="true"
            app:contentScrim="@color/white"
            app:expandedTitleMarginStart="10dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="114dp"
                    android:orientation="horizontal">

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:orientation="vertical">

                        <ImageView
                            android:id="@+id/imageViewQiangmai"
                            android:layout_width="50dp"
                            android:layout_height="50dp"
                            android:padding="4dp"
                            android:scaleType="centerInside"
                            android:src="@drawable/qiangmai3x" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="抢麦"
                            android:textColor="@color/gray3"
                            android:textSize="15sp" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:orientation="vertical">

                        <ImageView
                            android:id="@+id/imageViewHechang"
                            android:layout_width="50dp"
                            android:layout_height="50dp"
                            android:padding="4dp"
                            android:scaleType="centerInside"
                            android:src="@drawable/hechang3x" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="合唱"
                            android:textColor="@color/gray3"
                            android:textSize="15sp" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:orientation="vertical">

                        <ImageView
                            android:id="@+id/imageViewQingchang"
                            android:layout_width="50dp"
                            android:layout_height="50dp"
                            android:padding="4dp"
                            android:scaleType="centerInside"
                            android:src="@drawable/qingchang3x" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="清唱"
                            android:textColor="@color/gray3"
                            android:textSize="15sp" />
                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:orientation="vertical">

                        <ImageView
                            android:id="@+id/imageViewGefang"
                            android:layout_width="50dp"
                            android:layout_height="50dp"
                            android:padding="4dp"
                            android:scaleType="centerInside"
                            android:src="@drawable/gefang3x" />

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:text="歌房"
                            android:textColor="@color/gray3"
                            android:textSize="15sp" />
                    </LinearLayout>

                </LinearLayout>

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/recyclerView"
                    android:layout_width="match_parent"
                    android:layout_height="135dp"
                    android:layout_marginRight="15dp"
                    android:layout_marginBottom="15dp"
                    android:orientation="horizontal"></android.support.v7.widget.RecyclerView>

            </LinearLayout>

            <ImageView
                android:id="@+id/image"
                android:layout_width="50dp"
                android:layout_height="50dp"
                android:layout_gravity="center"
                android:scaleType="centerCrop"
                android:src="@drawable/logo3"
                android:visibility="gone"
                app:layout_collapseMode="parallax" />
            <!--标题-->
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:visibility="gone"
                app:layout_collapseMode="pin"
                app:title="Toolbar" />
        </android.support.design.widget.CollapsingToolbarLayout>
        <!--选项卡-->
        <android.support.design.widget.TabLayout
            android:id="@+id/tabLayout"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:background="@color/white"
            app:tabBackground="@null"
            app:tabGravity="fill"
            app:tabIndicatorColor="@color/colorPrimary"
            app:tabIndicatorFullWidth="false"
            app:tabMode="fixed"
            app:tabRippleColor="@null"
            app:tabSelectedTextColor="@color/colorPrimary"
            app:tabTextAppearance="@style/TabLayoutTextStyleSongType"
            app:tabTextColor="@android:color/black" />

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/nestedScrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <android.support.v4.view.ViewPager
            android:id="@+id/viewPager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/white"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />
    </android.support.v4.widget.NestedScrollView>

</android.support.design.widget.CoordinatorLayout>

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

Edgar-Dong commented 5 years ago

遇到同样的问题,求解决办法。

scwang90 commented 5 years ago

可以设置属性避免这个问题

        app:srlFooterTranslationViewId="@+id/recyclerView"

具体参考 demo