This is a bug in Appcompat v24.0.0
.
References: https://code.google.com/p/android/issues/detail?id=213895
In order to minimize the delay in elevation
drawing, set the duration to 1ms in your own StateListAnimator
and apply it to AppbarLayout
.
appbar_always_elevated.xml in animator-v21 folder under res directory.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<objectAnimator android:propertyName="elevation"
android:valueTo="8dp"
android:valueType="floatType"
android:duration="1"/>
</item>
</selector>
In AppbarLayout :
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="300dp"
android:fitsSystemWindows="true"
android:stateListAnimator="@animator/appbar_always_elevated"
android:theme="@style/AppTheme.AppBarOverlay">
</android.support.design.widget.AppBarLayout>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…