First off, I know that this question has been asked before, but it hasn't been answered before. I hope someone can give me an answer.
In my application, I use the Toolbar from Appcompat_v7 (API 21). This is my code:
<android.support.v7.widget.Toolbar style="@style/DarkActionbarStyle" android:id="@+id/toolBar" android:layout_width="match_parent" android:layout_height="@dimen/actionbar_height" />
And this is the ToolBar style I use:
<style name="DarkActionbarStyle" parent="@style/Widget.AppCompat.Toolbar"> <item name="android:background">?attr/colorPrimary</item> <item name="titleTextAppearance">@style/ActionBarTitle</item> <item name="android:elevation">2dp</item> <item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item> <item name="theme">@style/ThemeActionBarDark</item> </style> <style name="ThemeActionBarDark" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <item name="actionBarItemBackground">@drawable/btn_dark_orange</item> <item name="selectableItemBackground">@drawable/btn_dark_orange</item> </style>
The problem is, that elevation doesn't work pre-lollipop. So my question is: Is it possible to have a shadow under the ToolBar on pre-lollipop devices?
This worked for me very well:
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/primary" card_view:cardElevation="4dp" card_view:cardCornerRadius="0dp"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/primary" android:minHeight="?attr/actionBarSize" /> </android.support.v7.widget.CardView>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With