Make AppBarLayout respond to scrolling in WebView

前端 未结 2 1204
别跟我提以往
别跟我提以往 2021-02-01 08:17

In the design support Library (from I/O) Google introduced the AppBarLayout. I\'m trying to make the Toolbar animate out of the screen when the user scrolls through a website in

2条回答
  •  生来不讨喜
    2021-02-01 08:53

    Things placed inside CoordinatorLayout must be designed and implemented to work with it or it will not coordinate with any other sibling views. But well ... Toolbar is not designed for that. AppBarLayout is just an component that is prepared to make Toolbar works perfectly with CoordinatorLayout.

    LinearLayout is not designed to work with CoordinatorLayout.It is for more easy, you just need to add an attribute to the LinearLayout telling its scroll behavior

    
    

    you can try make AppBarLayout respond to the WebView by this

    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    

    since ScrollView is now a direct child of CoordinatorLayout.

    
    
        ...
    
    

    ScrollView was not designed to work with CoordinatorLayout (again). You need to use the another one, NestedScrollView, provided in Android Support Library v4, which is designed to work with CoordinatorLayout since born.

    And with the same reason, please note that the classic ListView doesn't work with CoordinatorLayout as well. Only RecyclerView works.

提交回复
热议问题