Android: Toolbar elevation / Shadow -


i know why toolbar cast shadow if nestedscrollview there (i've got example internet)

<android.support.design.widget.coordinatorlayout     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:layout_width="match_parent"     android:layout_height="match_parent">      <android.support.v4.widget.nestedscrollview         android:layout_width="match_parent"         android:layout_height="match_parent"         app:layout_behavior="@string/appbar_scrolling_view_behavior">          <!-- scrolling content -->      </android.support.v4.widget.nestedscrollview>      <android.support.design.widget.appbarlayout         android:layout_height="wrap_content"         android:layout_width="match_parent">          <android.support.v7.widget.toolbar             xmlns:android="http://schemas.android.com/apk/res/android"             xmlns:local="http://schemas.android.com/apk/res-auto"             android:id="@+id/toolbar"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:minheight="?attr/actionbarsize"             android:background="?attr/colorprimary"             local:theme="@style/themeoverlay.appcompat.dark.actionbar"             local:popuptheme="@style/themeoverlay.appcompat.light"             />     </android.support.design.widget.appbarlayout>  </android.support.design.widget.coordinatorlayout> 

this toolbar (without nestedscrollview) don't cast shadow:

<android.support.design.widget.coordinatorlayout     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:layout_width="match_parent"     android:layout_height="match_parent">      <android.support.design.widget.appbarlayout         android:layout_height="wrap_content"         android:layout_width="match_parent">          <android.support.v7.widget.toolbar             xmlns:android="http://schemas.android.com/apk/res/android"             xmlns:local="http://schemas.android.com/apk/res-auto"             android:id="@+id/toolbar"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:minheight="?attr/actionbarsize"             android:background="?attr/colorprimary"             local:theme="@style/themeoverlay.appcompat.dark.actionbar"             local:popuptheme="@style/themeoverlay.appcompat.light"             />     </android.support.design.widget.appbarlayout>  </android.support.design.widget.coordinatorlayout> 

i can post pictures, if needed, have no clue why happen. i've tried far:

  • setting cliptopadding="false" on parent linear layout
  • manually set elevation (my device not pre-lollipop)
  • seting outlineprovider="bounds" on view
  • setting android:hardwareaccelerated="true" on androidmanifest.xml

edit: i've solved using tag. check answer code.

researching little bit more, found out merge tag trick. tag can merge toolbar.xml in parent layout take care of z-ordering , place toolbar intended.

<merge xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <android.support.design.widget.coordinatorlayout     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:layout_width="match_parent"     android:layout_height="match_parent">      <android.support.design.widget.appbarlayout         android:layout_height="wrap_content"         android:layout_width="match_parent">          <android.support.v7.widget.toolbar             xmlns:android="http://schemas.android.com/apk/res/android"             xmlns:local="http://schemas.android.com/apk/res-auto"             android:id="@+id/toolbar"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:minheight="?attr/actionbarsize"             android:background="?attr/colorprimary"             local:theme="@style/themeoverlay.appcompat.dark.actionbar"             local:popuptheme="@style/themeoverlay.appcompat.light"             />     </android.support.design.widget.appbarlayout>  </android.support.design.widget.coordinatorlayout> </merge> 

and no, asking here not first thing did, luck find tag in less hour after post here. anyway, here solution.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -