CoordinatorLayout not working

两盒软妹~` 提交于 2019-12-05 01:31:15

I believe you need to make your ListView implement both ScrollingView and NestedScrollingChild interfaces.

It's not the easiest thing, but you should be able to do it if you look at RecyclerView's source code. It makes use of a NestedScrollingChildHelper and you should be able to do the same.

Currenlty not all views have the expected behavior with the CoordinatorLayout.

Your views should implement the NestedScrollView interface and have to handle the nested scroll events.

The RecyclerView and the NestedScrollView (version 22) support this behavior. However you can use also the AbsListView (ListView and GridView) but only with API21+.

Just add something like this:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
     listView.setNestedScrollingEnabled(true);
}

It depends on what you are showing in your ViewPager. If you use a list / recyclerview, it should scroll correctly.

Views can declare a default Behavior by using the CoordinatorLayout.DefaultBehavior(YourView.Behavior.class) annotation,or set it in your layout files by with the app:layout_behavior="com.example.app.YourView$Behavior" attribute. This framework makes it possible for any view to integrate with CoordinatorLayout.

So I think solution here is override the AppBarLayout.Behavior class

This is work for me.

It is code for GridView. But you can extend ListView instead of GridView.

https://gist.github.com/sakurabird/6868765

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