协调器布局 - 锚定视图不滚动,固定 -

时间:2015-09-12 13:12:21

标签: android android-coordinatorlayout

我有一个固定在应用栏上的ImageView。问题是我希望图像视图使用随后的NestedScrollView滚出屏幕,但这不会发生。它固定在工具栏上。帮助

我试过

  • 将锚定视图放置在NestedScrollView之前,但隐藏了滚动视图后面的ImageView。
  • 将ImageView锚定到NestedScrollView
  • 将ImageView锚定到NestedScrollView的子级

这里缺少什么?它有可能吗?

这是XML

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    android:id="@+id/main_content"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000000"
    android:clickable="true"
    android:fitsSystemWindows="true"
    android:focusable="true"
    android:focusableInTouchMode="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/detail_backdrop_height"
        android:clickable="true"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/backdrop"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                android:src="@drawable/splash_anim_10"
                app:layout_collapseMode="parallax"/>


            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>


    <android.support.v4.widget.NestedScrollView
        android:id="@+id/scroll_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            android:id="@+id/scroll_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            >

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="400dp"
                android:background="#ffccdd"/>

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="400dp"
                android:background="#ffccdd"/>

        </LinearLayout>

    </android.support.v4.widget.NestedScrollView>


    <ImageView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:clickable="true"
        android:src="@drawable/detail_image"
        app:layout_anchor="@id/appbar"
        app:layout_anchorGravity="bottom|left|start"
        app:layout_scrollFlags="scroll"
        />
</android.support.design.widget.CoordinatorLayout>

0 个答案:

没有答案