我爲我的應用程序使用應用程序主題,其中操作欄標誌對於該主題爲真。我的所有活動都顯示了相同的操作欄。如何使用CollapsingToolbarLayout而不是使用應用程序主題操作欄進行特定的活動?
如何使用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>
但它不工作,我的活動處處顯示着應用主題行動吧。
我已經試過這種方式沒有爲我工作。 – 0xalihn
你會得到什麼? –
您尚未使用任何圖像進行摺疊。使用圖像它將工作 –