0
继this教程中,我有这个CollapsingToolbarLayout
:使用CollapsingToolbarLayout,我怎样才能将其设置为支持操作栏?
<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|enterAlways|enterAlwaysCollapsed">
<ImageView
android:id="@+id/blurred_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="ContentDescription" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/defaultimage"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7"
tools:ignore="ContentDescription"
android:id="@+id/profilePicture" />
</android.support.design.widget.CollapsingToolbarLayout>
不过,我需要使用setSupportActionBar()
这样我就可以使用setTitle()
,setHomeAsUpEnabled()
等方法。但是,显然CollapsingToolbarLayout
不能投射到Toolbar
,并且setSupportActionBar()
方法只接受Toolbar
方法。
是否有替代方法来设置它?
通过https://guides.codepath.com/android/Handling-Scrolls-with-CoordinatorLayout – Pavya
为什么不把你的'ImageView'包装在'Toolbar'中? –
@MikeM。不错的想法,但它似乎像我的'ImageView'失去了他们的对齐。 (其中一个居中,现在它在屏幕的左侧) –