1

i have a problem getting a shadow on AppBarLayout. Following is xml layout of my activity, can anyone see where the problem is ? I checked few very similar questions on here and everything should be set correctly ...

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".ui.main.MainActivity"

    >

    <android.support.design.widget.AppBarLayout
        android:id="@+id/main_app_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        app:elevation="15dp"
        >

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/main_collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
            app:collapsedTitleTextAppearance="@style/Base.Widget.AppCompat.Toolbar"
            app:expandedTitleTextAppearance="@style/Base.Widget.AppCompat.Toolbar"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            >

            <android.support.percent.PercentRelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                app:layout_collapseMode="parallax"
                >

                ... Content ...

            </android.support.percent.PercentRelativeLayout>

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

            </android.support.v7.widget.Toolbar>

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

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

    <android.support.v7.widget.RecyclerView
        android:id="@+id/main_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginEnd="1dp"
        android:layout_marginRight="1dp"
        android:paddingBottom="@dimen/main_recycler_bottom_padding"
        android:clipToPadding="false"
        android:overScrollMode="never"
        android:layout_below="@+id/app_bar_layout"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/attribute_add"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:layout_marginBottom="@dimen/default_padding"
        app:borderWidth="0dp"
        android:backgroundTint="@color/colorPrimary"
        android:src="@drawable/ic_add_white"/>

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

Also, there's is one small feature in Android System alarm app, they're adding shadow to the toolbar only when content of activity is scrolled down, anyone has any pointers to how should such thing be achieved ?

TheJudge
  • 576
  • 1
  • 9
  • 30

0 Answers0