查看log
A/art: art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: can't call void android.view.View.setElevation(float) on null object
解決方法
android:stateListAnimator="@null"
但是toolbar沒(méi)有陰影了, 經(jīng)調(diào)查此bug只出現(xiàn)在API21上,所以在代碼中判斷SDK版本即可
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) {
appBar.setStateListAnimator(null);
}