Search code examples
javaandroidandroid-toolbar

Android Toolbar : shadow on top instead of bottom


I use the standard Android Toolbar android.support.v7.widget.Toolbar

https://developer.android.com/reference/android/support/v7/widget/Toolbar.html

I want to place this toolbar at the bottom of my screen => I want the shadow at the top and not at the bottom of the toolbar.

How can I do this?

Thanks !


Solution

  • You can define the following gradient in your drawables folder

        <shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#000"
        android:angle="90"
        />
    </shape>
    

    And then use it in your layout as follows

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <android.support.v7.widget.Toolbar
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_gravity="bottom">
    
            </android.support.v7.widget.Toolbar>
    
        <View android:background="@drawable/drop_shadow_tab"
            android:layout_width="match_parent"
            android:layout_height="5dp"
            android:layout_gravity="bottom"
            android:layout_marginBottom="50dp"/>
    
    </FrameLayout>
    

    Probably this is what you wanted. :)