In Appcompat v24.0.0 causes rendering of shadow/elevation to AppbarLayout
after Activity is visible. And a lag can easily be seen in shadow drawing to AppbarLayout
.
And this lag was not there in previous Appcompat library version.
Tested using both Appcompat v24.0.0 and Appcompat v23.4.0, shadow drawing clearly seen in the new version.
@Vipul Asri given us a good answer, but the appbar_always_elevated.xml should be into animator-v11 instead of animator-v21 folder. The layout that has the AppbarLayout is that should be into a v21 folder.
Summarising, the structure is like this:
Note that there are two a_layout_wich_has_the_appbarlayout.xml files (AppbarLayout in v21 folder with android:stateListAnimator property and in a non v21 folder without this property).
Take a look:
In a non v21 layout folder:
And, in v21 layout folder:
EDIT
Curiously, if you are using the AppbarLayout with a TabLayout, the shadow is drawn instantly, but notice that if you are using with the android:stateListAnimator property this case, the shadow view is a bit different.
Chris Banes said here:
So if your
AppBarLayout
is not collapsible you can use this:I guess it is not a bug, a feature.
AppBarLayout's elevation animation duration is controlled by
R.integer.app_bar_elevation_anim_duration
which by default is150
.To remove the animation, just do the following and that's it:
<integer name="app_bar_elevation_anim_duration" tools:override="true">0</integer>
This is a bug in
Appcompat v24.0.0
.In order to minimize the delay in
elevation
drawing, set the duration to 1ms in your ownStateListAnimator
and apply it toAppbarLayout
.appbar_always_elevated.xml in animator-v21 folder under res directory.
In AppbarLayout :