【发布时间】:2016-08-11 20:13:34
【问题描述】:
我现在正在使用的应用程序中的View 层次结构存在问题。
其中一个屏幕如下所示:
<CoordinatorLayout>
<AppBarLayout>
<Toolbar/>
</AppBarLayout>
<RecyclerView>
... items, some of which are horizontal Recyclers...
</RecyclerView>
</CoordinatorLayout>
整个想法是在向下滚动RecyclerView 内容时很好地拥有Toolbar 视差。
整个事情运行得相当好,但是提到的视差行为存在问题(这是通过自定义 AppBarLayout.ScrollingViewBehavior 实现完成的)。
有两种情况,取决于用户在滚动时关注的项目:
- 如果一个正常的孩子注意力集中,整个事情都会按预期工作 -
Toolbar视差进出。 - 如果基于 Recycler 的子对象获得焦点,则内容
RecyclerView将按预期滚动,但不会触发视差行为,从而使布局处于奇怪的中间状态。
知道为什么会发生这种情况以及如何获得正确的行为,也就是事件一直传递到CoordinatorLayout?
【问题讨论】:
标签: android material-design android-recyclerview parallax android-coordinatorlayout