状态栏正在使用CollapsingToolbarLayout滚动

时间:2017-03-24 05:37:18

标签: android

滚动时是应用程序的图片。你可以看到状态栏向上滚动,其余的内容应该坚持到顶部。此外,当向下滚动时,它应该停止在指定的最小宽度中折叠。一旦我介绍了ToolBar,它也停止了工作。在此之前,它按预期工作。

enter image description here

<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="com.wallpapermanager.ImageDetailsActivity">


<android.support.design.widget.AppBarLayout
    android:id="@+id/foo"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/grey_dark_transparent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="200dp"
        app:contentScrim="@android:color/transparent"
        android:fitsSystemWindows="true"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">


        <ImageView
            android:id="@+id/wallpaper_banner"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:scaleType="fitCenter"
            android:src="@drawable/wallpaper_placeholder"
            app:layout_collapseMode="parallax" />

        <!-- @Banner -->
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/grey_dark_transparent"
            app:layout_collapseMode="pin"
            app:statusBarScrim="@color/colorPrimaryDark"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

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


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

    

MAinfest

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

  <activity
            android:name=".ImageDetailsActivity"
            android:label="@string/title_activity_image_details"
            android:parentActivityName=".MainActivity"
            android:theme="@style/AppTheme.NoActionBar">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.sample.wallpapermanager.MainActivity" />
        </activity>
</application>

2 个答案:

答案 0 :(得分:0)

试试这个。适合我

<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:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/placements"
            android:scaleType="fitXY"/>

        <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>

答案 1 :(得分:0)

尝试将android:minHeight="200dp"CollapsingToolbarLayout移至AppBarLayout