Monday 15 March 2010

android - Shadow not working when using a Toolbar (Lollipop appcompat-v7) -



android - Shadow not working when using a Toolbar (Lollipop appcompat-v7) -

as know, elevation doesn't work on pre-lollipop devices. because of this, default app bar in appcompat-v7 uses "pseudo-shadow" texture, phone call it, emulate shadow. problem need utilize custom toolbar. when utilize custom toolbar, "pseudo-shadow" isn't present. looks flat. thought how add together shadow back? people have said on other forums add together framelayout foreground of " android:windowcontentoverlay" somehow overlaps toolbar. haven't found way working, sadly. , reason, in testing, "android:windowcontentoverlay" invisible anyway. not sure i'm doing wrong. :/

here's layout xml info toolbar:

<android.support.v7.widget.toolbar android:id="@+id/my_awesome_toolbar" android:layout_height="wrap_content" android:layout_width="match_parent" android:minheight="?attr/actionbarsize" android:background="?attr/colorprimary" app:theme="@style/themeoverlay.appcompat.dark.actionbar" app:popuptheme="@style/themeoverlay.appcompat.light" />

here's looks default appcompat appbar: http://imgur.com/0eie1vv

here's looks custom toolbar: http://imgur.com/ggec6tq

edit: help alanv, figured out how create shadow beneath toolbar. however, it's not same 1 comes default in appcompat. it's faint shadow, , if remember correctly it's same shadow resource had been used in older versions. i'm having hard time trying find resource default appcompat bar.

you set under toolbar.

<framelayout android:layout_width="match_parent" android:layout_height="match_parent"> <view android:layout_width="match_parent" android:layout_height="5dp" android:background="@drawable/toolbar_shadow" /> </framelayout>

@drawable/toolbar_shadow:

<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startcolor="@android:color/transparent" android:endcolor="#88333333" android:angle="90"/> </shape>

android

No comments:

Post a Comment