Can't call void android.view.View.setElevation(float) on null object in lapism/SearchView

眉间皱痕 提交于 2019-12-03 02:22:07

To fix this problem you have to update your XML file which contains SearchView and AppBarLayout. Add android:stateListAnimator="@null" to your AppBarLayout as shown below.

 <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:stateListAnimator="@null">

It shows warning that android:stateListAnimator="@null" attribute stateListAnimator is only used in API level 21. But I've checked source code of the library and it crashes in the SearchBehavior class when it tries to set mAppBarLayout.setStateListAnimator(null);

EDIT

As was mention in comments below this issue is related more to the android components native crash on scrolling in RecyclerView+CollapsingToolbarLayout

AppBarLayout's attribute app:elevation="..dp" helps to solve this problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!