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

안드로이드 스튜디오 ScrollingActivity를 안드로이드 마시멜로에서 실행했을 때 아래로 스와이프 하면 툴바가 늘어났다가 원래대로 돌아가는 효과를 없애고 싶습니다.

0 추천

안드로이드 스튜디오에서 새 프로젝트를 만들 때 ScrollingActivity를 선택하면 나오는 코드입니다.

activity_scrolling.xml

<?xml version="1.0" encoding="utf-8"?>
<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="jaebin.myapplication.ScrollingActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/app_bar_height"
        android:fitsSystemWindows="true"
        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"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways">

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

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

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

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

content_scrolling.xml

<?xml version="1.0" encoding="utf-8"?>
<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="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="jaebin.myapplication.ScrollingActivity"
    tools:showIn="@layout/activity_scrolling">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/text_margin"
        android:text="@string/large_text" />

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

툴바가 최대로 내려온 상태 (왼쪽)

툴바가 최대로 내려온 상태에서 아래로 스와이프하면 툴바가 늘어나면서 조금 더 아래로 내려옵니다. 손을 떼면 원래대로 돌아갑니다. (오른쪽) 저는 이 효과를 없애고 싶습니다.

툴바가 최대로 내려온 상태툴바가 최대로 내려온 상태에서 아래로 스와이프 할 경우 툴바가 늘어났다가 줄어드는 효과

익명사용자 님이 2016년 8월 9일 질문
2016년 8월 9일 수정

1개의 답변

0 추천

일단 CollapsingToolbarLayout 에서 layout_scrollFlags 속성 삭제해주시고

content_scrolling.xml 에서 app:layout_behavior="@string/appbar_scrolling_view_behavior" 부분 삭제 해보시기 바랍니다. 그래도 원하시는 동작이 안나오시면  

CollapsingToolbarLayout 를 쓰실 필요가 없으시다면 이 레이아웃을 빼보시기 바랍니다.

  

Development Guy (70,570 포인트) 님이 2016년 8월 10일 답변
...