我有一个CollapsingToolbarLayout
试图设置为类似于列出的第一个示例here。
我已遵循我可以找到的所有说明和文档。以下是我的XML:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/draw_insets_frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="@dimen/barHeight"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:id="@+id/photo_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/photo_placeholder">
<!--suppress AndroidLintContentDescription -->
<ImageView
android:id="@+id/toolbar_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"/>
<View
android:layout_width="match_parent"
android:layout_height="112dp"
android:background="@drawable/photo_background_protection" />
</FrameLayout>
<com.example.xyzreader.ui.MaxWidthLinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/detail_card_top_margin"
android:background="#fff"
android:elevation="2dp"
android:maxWidth="@dimen/detail_card_max_width"
android:orientation="vertical">
<LinearLayout
android:id="@+id/meta_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="@dimen/detail_metabar_vert_padding"
android:background="#333"
android:orientation="vertical"
android:paddingBottom="@dimen/detail_metabar_vert_padding"
android:paddingLeft="@dimen/detail_inner_horiz_margin"
android:paddingRight="@dimen/detail_inner_horiz_margin"
android:paddingTop="@dimen/detail_metabar_vert_padding">
<TextView
android:id="@+id/article_title"
style="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-condensed"
android:lineSpacingMultiplier="0.9"
android:paddingBottom="@dimen/detail_metabar_title_bottom_padding"
android:textColor="#fff"
android:textSize="@dimen/detail_title_text_size"
android:textStyle="bold" />
<TextView
android:id="@+id/article_byline"
style="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#8fff" />
</LinearLayout>
</com.example.xyzreader.ui.MaxWidthLinearLayout>
</FrameLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/main.toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways"
app:layout_collapseMode="pin"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<com.example.xyzreader.ui.ObservableScrollView
android:id="@+id/scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/article_body"
style="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/detail_inner_horiz_margin"
android:layout_marginRight="@dimen/detail_inner_horiz_margin"
android:lineSpacingMultiplier="@fraction/detail_body_line_spacing_multiplier"
android:paddingBottom="@dimen/detail_body_bottom_margin"
android:textColorLink="@color/theme_accent"
android:textSize="@dimen/detail_body_text_size" />
</com.example.xyzreader.ui.ObservableScrollView>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/share_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/fab_margin"
android:layout_marginRight="@dimen/fab_margin"
android:background="@drawable/add_fab_background"
android:contentDescription="@string/action_share"
android:elevation="@dimen/fab_elevation"
android:src="@drawable/ic_share"
android:stateListAnimator="@anim/fab_state_list_anim"
app:fabSize="normal"
app:layout_anchor="@id/toolbar"
app:layout_anchorGravity="bottom|end" />
很难描述这种行为,但是它不能正常运行。以下是图片,任何帮助将不胜感激: