9

新しいデザイン ライブラリを使用して Android アプリを開発しています。新しいGoogle フォト アプリで使用されているようなスクロール効果を作成したいと考えています。AppBarLayout を画面から完全にスクロールして、リサイクラー ビューがステータス バーの後ろにスクロールするようにしたいと思います。

アプリのテーマで windowTranslucentStatus を true に設定しました。メイン アクティビティの 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"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <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.design.widget.AppBarLayout>

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

下にスクロールするとこんな感じ。 ツールバーが完全に消えない

ツールバーが完全に消えるわけではありません。

手伝ってくれてありがとう!

4

5 に答える 5

1

これが私のアプリケーションで使用したものです

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

        <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>
于 2016-02-03T14:51:41.390 に答える
0

私の場合、 fitSystemWindows="false" を CoordinatorLayout に追加し、 fitSystemWindows="true" をその子に追加しました。あなたの場合は RecyclerView に追加しました。NavigationView、DrawerLayout、AppBarLayout、およびツールバーでは、「true」です。私はさまざまな値を試しましたが、私の場合は何かが壊れています。Android 5.1.1 と最新のサポート ライブラリ (23.0.1)。それが役に立てば幸い。

于 2015-10-06T14:32:13.390 に答える