После 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' в 'Панель инструментов'? –
@MikeM. Хорошая идея, но похоже, что мои ImageView 's потеряли выравнивания, которые они имели. (Один из них был сосредоточен, теперь он находится слева от экрана. –