将反向阴影和高程添加到CollapsingToolbar

时间:2017-05-07 19:57:32

标签: android material-design android-toolbar

我有CollapsingToolbar标题图片。我想在图像上添加阴影,而不是在下面。我尝试了app:elevation参数,但没有效果。

截图:

Layout now

Desired outcome

代码:

<android.support.design.widget.CoordinatorLayout
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:fitsSystemWindows="true">

<include layout="@layout/detail_content"/>

<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    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:statusBarScrim="@android:color/transparent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <ImageView
            android:id="@+id/imageViewToolbar"
            android:minHeight="500dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true"
            android:scaleType="centerCrop"
            app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
            app:layout_collapseMode="parallax" />

        <ProgressBar
            android:layout_gravity="center_vertical"
            android:id="@+id/progress"
            android:visibility="visible"
            android:layout_width="match_parent"
            android:layout_height="50dp" />

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:title=""
            android:layout_width="match_parent"
            android:layout_height="300dp"
            app:layout_collapseMode="pin"
            app:layout_scrollFlags="scroll|enterAlways"/>
    </android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fullscreenFAB"
    android:layout_width="64dp"
    android:layout_height="64dp"
    android:layout_margin="32dp"
    android:layout_gravity="center_vertical|left"
    android:clickable="true"
    app:fabSize="normal"
    android:background="@color/colorPrimary"
    app:layout_anchor="@+id/collapsing_toolbar"
    app:layout_anchorGravity="bottom|right"
    android:src="@drawable/ic_fullscreen_black_24dp"/>

1 个答案:

答案 0 :(得分:0)

您可以将ImageVIew和ProgressBar放入RelativeLayout并添加带阴影背景的视图:

prettier-eslint

同时在drawable文件夹中创建一个“gradient.xml”文件:

setOptions={{firstLineNumber: 10}}