mercredi 27 mai 2015

Shadow for toolbar

I have the following layout for one of my screens. I have used Toolbar instead of ActionBar to get the desired look of overlying FAB. The problem is when i scroll the list, the shadow doesn't show transparency. How to deal with this?

Here is complete layout xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
    xmlns:app="http://ift.tt/GEGVYd"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background">

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

    <View
        android:layout_width="match_parent"
        android:layout_height="@dimen/minimum_margin"
        android:layout_below="@id/app_bar"
        android:background="@drawable/toolbar_shadow" />

    <ListView
        android:id="@+id/show_all_categories"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/app_bar"
        android:paddingTop="@dimen/minimum_margin" />

    <com.melnykov.fab.FloatingActionButton
        android:id="@+id/fabButtonforAddAccount"
        android:layout_width="@dimen/fab_dimen"
        android:layout_height="@dimen/fab_dimen"
        android:layout_alignBottom="@id/app_bar"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="@dimen/negative_half_fab_dimen"
        android:layout_marginEnd="@dimen/global_margin"
        android:layout_marginRight="@dimen/global_margin"
        android:onClick="onAddNewCategory"
        android:src="@drawable/ic_add_white_24dp"
        app:fab_colorNormal="@color/accent" />
</RelativeLayout>

XML for shadow:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://ift.tt/nIICcg"
    android:shape="rectangle">
    <gradient
        android:angle="90"
        android:endColor="@color/shadow"
        android:startColor="@android:color/transparent" />
</shape>

XML for toolbar:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://ift.tt/nIICcg"
    xmlns:app="http://ift.tt/GEGVYd"
    android:layout_width="match_parent"
    android:layout_height="@dimen/app_bar_height"
    android:background="@color/primary"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

Aucun commentaire:

Enregistrer un commentaire