アクション バー フラグがそのテーマに対して true であるアプリケーションにアプリ テーマを使用しています。私のアクティビティはすべて同じアクションバーを表示しています。
メイン アプリ テーマのアクション バーを使用する代わりに、特定のアクティビティに CollapsingToolbarLayout を使用するにはどうすればよいですか?
アクティビティ クラスに以下のコードを追加しました。
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
CollapsingToolbarLayout collapsingToolbar =
(CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
collapsingToolbar.setTitle(cheeseName);
そして、これは私のレイアウトです:
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
しかし、それは機能していません.私のアクティビティは常にアプリテーマのアクションバーを表示しています.