它应该设置在 AppBarLayout 同级的父级还是在其同级内的第一个 Scrollable View 中?
使用 Material Design for Android ,有一些 视图 可以让我们根据其周围环境来处理布局的行为,其中之一是 CoordinatorLayout ,正如 本 CodePath 指南 所提到的:
CoordinatorLayout 扩展了完成许多 Google 的 Material Design 滚动效果的能力。目前,此框架中提供了几种方法,无需编写您自己的自定义动画代码即可使其工作。
我现在感兴趣的是:
- 扩展或收缩工具栏或标题空间以为主要内容腾出空间。
因此,我们将使用带有 app:layout_scrollFlags
设置的 工具栏 的 AppBarLayout 和带有 app:layout_behavior
的 AppBarLayout 的另一个 ViewGroup 兄弟。
我的问题是:我们应该将 app:layout_behavior
放在哪个确切的 ViewGroup(或者可能是 View)中?
到目前为止,我已经尝试过(他们都 工作过,他们都是 AppBarLayout 的兄弟姐妹):
滚动视图
可滚动视图中的第一个 ViewGroup
ViewGroup 中的 ScrollView
而这个没有用:
- 没有 Scrollable View 子项的 ViewGroup。
网上有很多例子,但没有一个真正说明你应该把它放在哪里,比如:
http://www.ingloriousmind.com/blog/quick-look-on-the-coordinatorlayout/ https://guides.codepath.com/android/Handling-Scrolls-with-CoordinatorLayout https://developer.android.com /training/basics/firstapp/building-ui.html https://www.bignerdranch.com/blog/becoming-material-with-android-design-support-library/
原文由 Evin1_ 发布,翻译遵循 CC BY-SA 4.0 许可协议
检查此链接: https ://developer.android.com/reference/android/support/design/widget/AppBarLayout.html
他们提到过,应该是
View
将显示在AppBarLayout
下,如下所示:在这个链接中:http: //guides.codepath.com/android/Handling-Scrolls-with-CoordinatorLayout