Material Design(九)--CoordinatorLayout和App Bar

CoordinatorLayout的其它主要使用实例包括app bar(即先前的action bar)和滚动技术。你也许已经在布局中使用Toolbar了,Toolbar允许你轻易地自定义外观和应用中图标部分与布局的集成。Design包在这一点走得更远:使用AppBarLayout允许Toolbar和其它的视图(如TabLayout提供了tab)对标记了ScrollingViewBehavior的兄弟视图中的滚动事件产生反馈。由此,你可以像这样创建布局:

 1 <android.support.design.widget.CoordinatorLayout
 2         xmlns:android=‘http://schemas.android.com/apk/res/android‘
 3         xmlns:app=‘http://schemas.android.com/apk/res-auto‘
 4         android:layout_width=‘match_parent‘
 5         android:layout_height=‘match_parent‘>
 6
 7      <! -- Your Scrollable View -->
 8     <android.support.v7.widget.RecyclerView
 9             android:layout_width=‘match_parent‘
10             android:layout_height=‘match_parent‘
11             app:layout_behavior=‘@string/appbar_scrolling_view_behavior‘ />
12
13     <android.support.design.widget.AppBarLayout
14             android:layout_width=‘match_parent‘
15             android:layout_height=‘wrap_content‘>
16    <android.support.v7.widget.Toolbar
17                   ...
18                   app:layout_scrollFlags=‘scroll|enterAlways‘>
19
20         <android.support.design.widget.TabLayout
21                   ...
22                   app:layout_scrollFlags=‘scroll|enterAlways‘>
23      </android.support.design.widget.AppBarLayout>
24 </android.support.design.widget.CoordinatorLayout>

现在,在用户使用RecyclerView的时候,AppBarLayout能够对通过使用子视图的滚动标签来控件他们如何滚进和滚出屏幕的事件进行响应。这些标签包括:

scroll:这个标签应该是想要滚出屏幕的所有视图的集合—对于那些并不使用这个标签的视图,他们而被订在屏幕的顶部。 enterAlways:这个标签确保任何向下的滑动都会使得这个视图可见,激活了“快速返回”模式。 exitUntilCollapsed:这个标签使得视图不会滚动出来,除非在退出之前该视图变得“collapsed”(它的minHeight)。

注意一点:所有使用scroll标签的视图必须在不使用该标签的视图之前声明。这将确保所有的视图从顶部退出,而把固定的元素落下。

时间: 2024-08-26 17:04:20

Material Design(九)--CoordinatorLayout和App Bar的相关文章

开发 Material Design+RxJava+Retrofit+MVP App 参考资料

前言 在开发一个基于 Material Design+RxJava+Retrofit+MVP 框架的 App 过程中学习的资料整理 —— 由G军仔分享 这里记录了我开发 大象 项目时,所学习的开发资料以及参考的开源项目,稍微整理了一下,全当笔记记录,跟大家一起分享,也许能给正在使用 RxJava + Retrofit + MVP + Material Design 框架开发的人一个参考学习,如果有人从我分享的资料当中学习到东西,那是我的荣幸,希望大家能与我一起努力. 之前看到很多人都使用 RxJ

Material Design(十)--CoordinatorLayout和App Bar

把Toobar直接添加到AppBarLayout里面给予了你enterAlwayCollapsed和exitUntilCollapsed这些滚动标签的访问权限,而不是对不同元素如何对collapsing作出响应的详细控件能力.要想获取后者的效果,你可以使用CollapsingToolbarLayout: 1 <android.support.design.widget.AppBarLayout 2 android:layout_height='192dp' 3 android:layout_wi

官方 Material Design App

[转]MaterialDesignCenter 发表回复 转: https://github.com/lightSky/MaterialDesignCenter MaterialDesignCenter Collection of material design libs and res. 如果你也有不错的Material Design相关资源,可直接Commit,但在Commit之前,请进行Preview changes,保持整体的美观性,图片的命名和规格可以参照已提交的图片. 欢迎大家Sta

Material Design 开发利器:Android Design Support Library 介绍

转自:https://blog.leancloud.cn/3306/ Android 5.0 Lollipop 是迄今为止最重大的一次发布,很大程度上是因为 material design —— 这是一门新的设计语言,它刷新了整个 Android 的用户体验.但是对于开发者来说,要设计出完全符合 material design 哲学的应用,是一个很大的挑战.Android Design Support Library 对此提供了很好的支持,里面汇集了很多重要的 material design 控

Android控件使用 — 12个Material Design风格控件的使用

项目在GitHub上的地址: https://github.com/Hebin320/MaterialDesignUse 1.AppBarLayout.ToolBar AppBarLayout 是继承LinerLayout实现的一个ViewGroup容器组件,它是为了Material Design设计的App Bar,支持手势滑动操作. AppBarLayout必须作为Toolbar的父布局容器,也可以配合CoordinatorLayout一起使用. ToolBar是谷歌新推出的代替Action

Material Design with the Android Design Support Library

Material Design with the Android Design Support Library 原文http://www.sitepoint.com/material-design-android-design-support-library/ Material Design,Android 5.0发布时为android app 和其他平台app引入的一门新的设计语言. 它带来了一些新的UI组件,如“Floating Action Button”.实施这些新组件,同时确保向后兼容

[翻译]Android 5.0之应用中实现材料设计—Material Design

上午的时候在刷Google+,看到了Abraham Williams转发了一篇强文,是Android Developers网站新发的一篇博客—Implementing Material Design in your Android App.觉得很前卫,对于新发布的Android版本号Android 5.0是一个很好的学习和了解的机会,所以就花了些时间把它翻译了下来,希望对自己.对其它人有所启发. 因为翻译Android开发博客和API也只是业余爱好,水平有限,其中不免有不准确的地方,所以把原文地

进入Material Design时代

由于本文引用了大量官方文档.图片资源,以及开源社区的Lib和相关图片资源,因此在转载的时候,务必注明来源,如果使用资源请注明资源的出处,尊重版权,尊重别人的劳动成果,谢谢! Material Design 官方Material Design详细介绍文档:http://www.google.com/design/spec/material-design/introduction.html 关于Material Design是Android 5.0系统的重头戏,并在以后App中将成为一种设计标准,而

【Android】进入Material Design时代

由于本文引用了大量官方文档.图片资源,以及开源社区的Lib和相关图片资源,因此在转载的时候,务必注明来源,如果使用资源请注明资源的出处,尊重版权,尊重别人的劳动成果,谢谢! Material Design 官方Material Design详细介绍文档:http://www.google.com/design/spec/material-design/introduction.html Material Design是Android 5.0系统的重头戏,并在以后App中将成为一种设计标准,而且随