마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

CollapsingToolbarLayout의 collapsing이 작동하지 않습니다 ㅠㅠ

0 추천

이게 RecyclerView를 갖는 게시판목록 xml입니다

<android.support.design.widget.CoordinatorLayout
    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="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".Activity.ArticleListActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/toolbar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways">

            <android.support.v7.widget.Toolbar
                android:id="@+id/list_toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/AppTheme.PopupOverlay">

                <TextView
                    android:id="@+id/boardName"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:gravity="center_vertical"
                    android:textColor="@color/textColorPrimary"
                    android:textSize="20dp" />

            </android.support.v7.widget.Toolbar>

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

    <include layout="@layout/content_article_list" />

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

그리고 include된 content_article_list.xml은 다음과 같습니다.

<com.malinskiy.superrecyclerview.SuperRecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/article_list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/windowBackground"
    android:clipToPadding="false"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

 

저 SuperRecyclerview는 FrameLayout을 상속받는 클래스로 해당 클래스 내부에 RecyclerView를 가지고 있습니다.

 

이런 구조인데 RecyclerView에서 아무리 스크롤링을 해도 Toolbar가 미동도 안합니다.

검색하다 안돼서 StackOverflow에서도 질문해보고 답변도 받아서 적용해보고 했지만 역시나 같네요

FrameLayout이 문제인가 싶었지만 Toolbar를 제외한 영역에 FrameLayout도 잘사용하더군요

layout_behavior를 코드로 FrameLayout(SuperRecyclerView)에 추가도 해줘봤지만 역시나...

 

지금상태로는 Toolbar가 StatusBar밑에 겹쳐있습니다.

    android:fitsSystemWindows="true"

 를 계층별로 적용해보고 했는데 안먹히네요 ㅠ

Bateaux (5,200 포인트) 님이 2018년 3월 13일 질문

1개의 답변

0 추천
해답을 찾았습니다. 다른분들에게도 도움이 됐으면 좋겠네요

저기 적힌 SuperRecyclerView가 FrameLayout를 상속받은 클래스지만 제대로 작동안되길래

빼버렸습니다.

NestedScrollView, RecyclerView를 FrameLayout 또는 SwipeRefreshLayout으로 감싸고

감싼 녀석에게 layout_behavior를 설정해둡니다.

NestedScrollView, RecyclerView는 setNestedScrollEnabled() 자체를 선언 안했습니다.

recyclerView에 setNestedScrollEnabled(false)를 아예 빼버리니까 작동이 잘됩니다.
Bateaux (5,200 포인트) 님이 2018년 3월 22일 답변
...