简体   繁体   中英

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 !

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. :)

只需将工具栏包装到AppBarLayout中

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM