【发布时间】:2016-10-19 08:02:15
【问题描述】:
所以我在 Activity 中使用 CoordinatorLayout 之类的......
<CoordinatorLayout>
<AppBarLayout>
<Toolbar/>
</AppBarLayout>
<FrameLayout> // For Fragments
</CoordinatorLayout>
Toolbar 使用 scroll|enterAlways 作为 Scrollflags。
在一个特定的片段中,我想在布局上实现视差效果,我再次使用CoordinatorLayout,但这会导致工具栏无法正常运行。
这是我在Fragment 的布局中使用它的方法:
<CoordinatorLayout>
<AppBarLayout>
<CollapsingToolbarLayout>
<Toolbar/>
</CollapsingToolbarLayout>
</AppbarLayout>
<RelativeLayout/> // Contains the Fragment's content
</CoordinatorLayout>
如何实现这两种效果?会不会是因为Fragment的CoordinatorLayout拦截了事件?
所以工具栏在滚动时隐藏,我需要使用滚动视差效果隐藏搜索功能
【问题讨论】:
-
一个
CoordinatorLayout就足够了。厨师也可能会破坏肉汤。 -
无论如何,当您最终将片段放回活动中时,为什么要在片段中复制活动中的内容(应用栏、工具栏、协调器)?你打算实施什么?也许是一张照片?
-
@ElvisChweya 哦,我认为 appbar 必须是
CoordinatorLayout的直接子代 :( 是的,它用于类似的东西,用于搜索功能。搜索应该在用户滚动时使用视差效果。 -
你能画出你设想的布局吗?我认为复制是多余的
-
@ElvisChweya 我也有这种感觉,但我不知道我还能怎么解决这个问题。让我在油漆中做点什么
标签: android android-coordinatorlayout