AppEarLayout上的EdgeEffect

时间:2016-02-17 06:32:19

标签: android material-design

我的视图中有一个CollapsingToolbar作为父元素,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:tools="http://schemas.android.com/tools"
    style="@style/XmatchYmatch"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/appbar_image_height"
        android:fitsSystemWindows="true"
        android:transitionName="@string/shared_element_anim_name"
        android:background="@color/red">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            style="@style/XmatchYmatch"
            android:minHeight="0dp"
            app:statusBarScrim="@color/translucent_black"
            app:expandedTitleTextAppearance="@android:color/transparent"
            android:fitsSystemWindows="true"
            app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">

            <RelativeLayout
                android:id="@+id/toolbar_content_parent"
                style="@style/XmatchYmatch"
                android:fitsSystemWindows="true"
                app:layout_collapseMode="parallax"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">

                <ImageView
                    android:id="@+id/toolbar_iv"
                    style="@style/XmatchYmatch"
                    android:scaleType="centerCrop"
                    tools:ignore="ContentDescription"/>

                <TextView
                    android:id="@+id/toolbar_title"
                    style="@style/ImageText.Title"
                    android:layout_alignParentBottom="true"
                    android:maxLines="2"/>

                <TextView
                    android:id="@+id/toolbar_dm"
                    style="@style/ImageText.Subtitle"
                    android:layout_above="@id/toolbar_title"
                    android:maxLines="2"/>
            </RelativeLayout>

            <include
                android:id="@+id/toolbar"
                layout="@layout/toolbar"/>

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

    <android.support.v4.widget.NestedScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        style="@style/XmatchYmatch">

    <LinearLayout
        android:id="@+id/section_parent"
        style="@style/XmatchYmatch.Vert"
        android:animateLayoutChanges="true"/>
</android.support.v4.widget.NestedScrollView>

    <FrameLayout
        style="@style/XmatchYwrap"
        android:background="@color/dark_red"
        app:layout_anchor="@id/detail_fragment"
        app:layout_anchorGravity="bottom|right|end">

        <Button
            android:id="@+id/button"
            style="@style/Subhead"
            android:layout_width="match_parent"
            android:background="?android:attr/selectableItemBackground"
            android:text="@string/button_text"
            android:textColor="@android:color/white"/>

        <ProgressBar
            android:id="@+id/sign_progress"
            style="@style/ProgressBar"
            android:layout_gravity="center"
            android:visibility="gone"/>
    </FrameLayout>

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

当我一直滚动到顶部时,我在Toolbar下方有一个边缘效果。像这样:

enter image description here

但我希望边缘效果低于StatusBar。像这样:

enter image description here

我该怎么做呢?

编辑:我尝试将NestedScrollView作为我的父母并且它有效。但那不是我想要的层次结构。

1 个答案:

答案 0 :(得分:0)

您可以尝试通过添加以下行

来更改AppTheme中边缘效果的颜色

<item name="android:colorEdgeEffect">@color/my_color</item>

希望这有帮助。