3

ScrollView で CollapsingToolbarLayout を使用しようとしていますが、機能しません。私はこれを試します:

<android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">


        <android.support.v4.widget.NestedScrollView
                android:layout_width="match_parent"
                android:layout_below="@+id/toolbar"
                android:scrollbars="none"
                android:overScrollMode="never"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"
                app:behavior_overlapTop="192dp"
                android:layout_height="match_parent">

            <LinearLayout android:layout_width="match_parent"
                          android:orientation="vertical"
                          android:padding="@dimen/medium_padding"
                          android:layout_height="match_parent">

                          <!-- my content -->


            </LinearLayout>

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



        <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_scrollFlags="scroll|enterAlways"></android.support.v7.widget.Toolbar>
        <ImageView
                android:src="@drawable/fondo_drawer"
                app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:scaleType="fitXY"
                app:layout_collapseMode="parallax"
                android:minHeight="100dp"/>

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

ScrollView と NestedScrollView のテストに失敗しました。

何か案は?前もって感謝します!

4

2 に答える 2

0

私は同じ間違いに出くわしましたabhishek's答えは完璧です。

少し追加したいです。AppBarLayout に対してのみ行う場合は機能しますandroid:fitsSystemWindows="true"。and に対して設定する必要はありません。それらは一部でImageViewあり、これはそれらにも適用されるためです。ToolBarAppBarLayout

ここを見てください - https://medium.com/google-developers/why-would-i-want-to-fitssystemwindows-4e26d9ce1eec#.an1hvz44l

システム ウィンドウは、システムが非対話型 (ステータス バーの場合) または対話型 (ナビゲーション バーの場合) コンテンツを描画する画面の部分です。

ほとんどの場合、アプリでステータス バーやナビゲーション バーの下に描画する必要はありませんが、描画する場合は、インタラクティブな要素 (ボタンなど) がそれらの下に隠れていないことを確認する必要があります。これが android:fitsSystemWindows=“true” 属性のデフォルトの動作です。ビューのパディングを設定して、コンテンツがシステム ウィンドウに重ならないようにします。

于 2016-09-27T08:17:18.177 に答える