CollapsingToolbarLayout ImageView is not scrollable

前端 未结 3 1967
情深已故
情深已故 2021-02-06 04:53

Using cheesesquare - android support library example is it possible to make the Header ImageView scroll-able?



        
3条回答
  •  天涯浪人
    2021-02-06 04:57

    OK, I did some research in the bug reports, and this is a known bug within the Design Support Library.

    Check out the bug report here

    Excerpt

    I have taken a look at the implementation that backs CoordinatorLayout/AppBarLayout/the Behavior classes etc. The AppBarLayout uses the behaviour defined in AppBarLayout.Behavior by default. This extends ViewOffsetBehavior which in turn extends Behavior. The base Behavior class has the methods onInterceptTouchEvent() and onTouchEvent(), both of which return false (meaning "we don't want to handle touch events"). These methods are not overridden by either ViewOffsetBehavior or AppBarLayout.Behavior, meaning that the touch is left unhandled - which is why it does nothing.

    A possible workaround for third-party developers would be to extend AppBarLayout.Behavior and implement onInterceptTouchEvent() and onTouchEvent() and manipulate the app bar accordingly.

    Videos

    These show the current and intended behavior. These are also from the bug report.

    • https://youtu.be/xWadOVEaTSY
    • https://youtu.be/J8ITp6RusZo

提交回复
热议问题