Tencent / QMUI_Android

提高 Android UI 开发效率的 UI 库
http://qmuiteam.com/android
Other
14.46k stars 2.68k forks source link

How can I use stickyHeader of QMUIStickySectionLayout in CoordinatorLayout?? #745

Closed zzy904494436 closed 5 years ago

zzy904494436 commented 5 years ago

运行环境

具体问题描述

我仔细看了wiki 关于QMUIStickySectionLayout的用法,我想在一个很经典的布局中使用QMUIStickySectionLayout,但是出现Header并不能sticky在顶部 因为我用了

app:layout_behavior="@string/appbar_scrolling_view_behavior"

还是

NestedScrollView

? 请问我需要自定义behavior解决这个问题吗? 还是有QMUI系的其他view可以解决这个问题?

`<?xml version="1.0" encoding="utf-8"?> <com.qmuiteam.qmui.widget.pullRefreshLayout.QMUIPullRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/refresh_album" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior">

<androidx.coordinatorlayout.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/appbar_album"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:elevation="0dp"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <com.google.android.material.appbar.CollapsingToolbarLayout
            android:id="@+id/collapsing_album"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="@color/bg_theme"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
            app:statusBarScrim="@color/bg_theme">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.5">

                <androidx.appcompat.widget.LinearLayoutCompat
                    android:id="@+id/ll_top_album"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginTop="?attr/actionBarSize"
                    android:orientation="horizontal"
                    android:padding="10dp"
                    app:layout_behavior="@string/appbar_scrolling_mycore_behavior">

                    <androidx.appcompat.widget.AppCompatImageView
                        android:id="@+id/acimg_preview_album"
                        android:layout_width="150dp"
                        android:layout_height="match_parent"
                        android:layout_margin="10dp"
                        android:padding="10dp"
                        android:scaleType="fitXY"
                        android:src="@drawable/test" />

                    <androidx.appcompat.widget.LinearLayoutCompat
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:gravity="center_vertical"
                        android:orientation="vertical">

                        <androidx.appcompat.widget.AppCompatTextView
                            android:id="@+id/actv_title_album"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:maxLines="2"
                            android:textColor="@color/color_btn_white"
                            android:textSize="20sp"
                            android:textStyle="bold" />

                        <androidx.appcompat.widget.AppCompatTextView
                            android:id="@+id/actv_tag_album"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:maxLines="1"
                            android:textColor="@color/color_btn_white"
                            android:textSize="14sp"
                            android:textStyle="bold" />

                        <androidx.appcompat.widget.AppCompatTextView
                            android:id="@+id/actv_time_album"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:maxLines="1"
                            android:textColor="@color/color_normal_tips_default"
                            android:textSize="13sp"
                            android:textStyle="bold" />

                        <androidx.appcompat.widget.AppCompatTextView
                            android:id="@+id/actv_info_album"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:maxLines="5"
                            android:textColor="@color/color_btn_white"
                            android:textSize="12sp"
                            android:textStyle="normal" />
                    </androidx.appcompat.widget.LinearLayoutCompat>

                </androidx.appcompat.widget.LinearLayoutCompat>

            </RelativeLayout>

            <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbar_album"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light">

                <include
                    layout="@layout/layout_title_common"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />

            </androidx.appcompat.widget.Toolbar>

        </com.google.android.material.appbar.CollapsingToolbarLayout>

    </com.google.android.material.appbar.AppBarLayout>

    <androidx.core.widget.NestedScrollView
        android:id="@+id/nested_album"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <com.qmuiteam.qmui.layout.QMUILinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="-10dp"
            android:orientation="vertical"
            android:padding="10dp">

            <com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout
                android:id="@+id/section_album"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="10dp" />

        </com.qmuiteam.qmui.layout.QMUILinearLayout>

    </androidx.core.widget.NestedScrollView>

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab_album"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="12dp"
        android:clickable="true"
        android:src="@drawable/test"
        app:layout_anchor="@id/appbar_album"
        app:layout_anchorGravity="bottom|right|end" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

</com.qmuiteam.qmui.widget.pullRefreshLayout.QMUIPullRefreshLayout>

问题截图

device-2019-11-12-173247 device-2019-11-12-173247

help me please!

zzy904494436 commented 5 years ago

wow!我看到了QMUICollapsingTopbarlayout 我应该试一试的 sorry!