CoordinatorLayout、AppBarLayout、CollapsingToolbarLayout的用法,让Toolbar与系统栏融为一体
CoordinatorLayout其实是加强版的FrameLayout布局,可以监听期所有子控件的各种事件,由Design Support库提供的,能体现Material Design 的魔力。能解决其子控件互相遮挡问题。
所以,当Toolbar控件与RecycledView控件互相时,所以要放到CoordinatorLayout布局中。 AppBarLayout相当于垂直方向 的LinearLayout布局,它在内部做了很多滚动事件的封装,也应用了Material Design 的设计理念。由于AppBarLayout严重依赖CoordinatorLayout,所以可以让它内部的Toolbar与RecycledView
避免互相遮挡。
AppBarLayout来自design兼容包,使用需要添加依赖。android studio 添加依赖如下:依赖库必须是最新的。
implementation 'com.android.support:design:27.1.0'
CollapsingToolbarLayout是一个作用在Toolbar基础之上的布局,它也是由Design Support库提供的,它让Toolbar的效果变得更丰富,不仅展示一个标题栏,而且加载图片。所以,修饰Toolbar的属性最好用来修饰CollapsingToolbarLayout,这样可以让效果最好,比如
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
在上述三者的布局中加入ImageView控件,为了使Toolbar能系统状态栏,需要在上述四个布局代码中加入
android:fitsSystemWindows="true"
另外还要在values/styles.xml文件中修改如下:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:statusBarColor">@android:color/transparent</item>//这是需要增加的属性,让系统栏透明,从而让Toolbar与系统栏融为一体
</style>
CoordinatorLayout、AppBarLayout、CollapsingToolbarLayout的用法,让Toolbar与系统栏融为一体的更多相关文章
- CoordinatorLayout, AppBarLayout, CollapsingToolbarLayout使用
本文介绍Design Support Library中CoordinatorLayout, AppBarLayout, CollapsingToolbarLayout的使用. 先列出了Design S ...
- Material Design之CoordinatorLayout+AppBarLayout实现上滑隐藏ToolBar
ok,今天继续更新Material Design系列!!! 废话不说,先看看效果图吧: 好了,现在来讲讲上图是怎么实现的吧!讲之前先讲讲几个控件: CoordinatorLayout 该控件也是De ...
- Android----Material Design之(FloatActionButton,CoordinatorLayout,CollapsingToolbarLayout,AppBarLayout,TabLayout等)
Material Design 的一些UI 平常开发还是用的比较多的,以前没写,最近总结一下,写一篇博客,要求版本在5.0以上. 主要介绍了FloatActionButton,CoordinatorL ...
- 【转】Android M新控件之AppBarLayout,NavigationView,CoordinatorLayout,CollapsingToolbarLayout的使用
Android M新控件之AppBarLayout,NavigationView,CoordinatorLayout,CollapsingToolbarLayout的使用 分类: Android UI ...
- [Android] Android利用Coordinatorlayout+AppbarLayout实现折叠式布局
折叠式布局在App中相当常见,给人一种科技感,充满良好的用户体验. 本文就以两个简单的例子,来举例说明基本折叠式布局: 首先需要在app/build.gradle下添加如下依赖: compile 'c ...
- AppbarLayout的简单用法
在许多App中看到, toolbar有收缩和扩展的效果, 例如: appbar.gif 要实现这样的效果, 需要用到: CoordinatorLayout和AppbarLayout的配合, 以及实 ...
- Android学习之CoordinatorLayout+AppBarLayout
•AppBarLayout 简介 AppbarLayout 是一种支持响应滚动手势的 app bar 布局: 基本使用 新建一个项目,命名为 TestAppBarLayout: 修改 activity ...
- Android CoordinatorLayout + AppBarLayout(向上滚动隐藏指定的View)
在新的Android Support Library里面,新增了CoordinatorLayout, AppBarLayout等. 实现的效果: 向下滚动RecylerView,Tab会被隐藏,向上滚 ...
- DrawerLayout、CoordinatorLayout、CollapsingToolbarLayout的使用--AndroidSupportDesign练手
先po一张效果图 PS:原谅题主的懒惰吧.. 看着是不是很酷炫,那是因为5.0的动画做得好,代码其实没有多少,搞清楚这个布局的层次关系很重要. 废话不多说了,先来看布局文件 最外层是一个DrawerL ...
随机推荐
- 一个涉及到浮点寄存器的CM
这次找小伙伴要了他的一个CM,怎么说呢,这CM让我学到了不少,其实搞出来后感觉不难,就是有不少FPU浮点相关的指令和FPU寄存器完全没学过,查了不少资料,学到了很多 打开是这样 无壳程序,我们直接od ...
- python 之 循环语句
python提供了for循环和while循环以及嵌套循环(在python中没有do..while循环) while 循环语法: while 判断条件: 执行语句...... 实际案例: numbers ...
- 论文笔记:Tracking by Natural Language Specification
Tracking by Natural Language Specification 2018-04-27 15:16:13 Paper: http://openaccess.thecvf.com/ ...
- Vue.directive自定义指令
Vue除了内部指令,我们也可以定义一些属于自己的指令,比如我们要定义一个v-diy的指令,作用就是让文字变成红色. 写好了这个功能,我们现在就自己定义一个全局的指令.我们这里使用Vue.directi ...
- (转载)C#工具箱Menustrip控件中分割线的设置方法
最近编C#程序,因为初学,不是太清楚,碰到了toolstripMenu中分割线设置的问题.遍寻中文网页,都是语言不详的,甚是呕人. 上网找了个外文网站,给的答案甚是详细,先贴在下面. http://w ...
- 广告api
appnexus: report timezoom brightroll: report timezoom criteo: report1 report2 用fiddle抓包查看 Taboola: ...
- mysql中if()函数使用
博主原创,转载请注明出处: 在mysql中if()函数的用法类似于java中的三目表达式,其用处也比较多,具体语法如下: IF(expr1,expr2,expr3),如果expr1的值为true,则返 ...
- 【BZOJ】4008: [HNOI2015]亚瑟王
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=4008 这题主要在于:先算概率,再算期望! 一轮一轮的计算似乎很复杂,每一轮它其实是可以看作 ...
- Codeforces Round #271 (Div. 2) F. Ant colony 线段树
F. Ant colony time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- IDEA 的Class not found: "..."Empty test suite
Junit测试的时候出现 IDEA 的Class not found: "..."Empty test suite问题. 尝试一下解决方法: 第一种方法: 1.modules&g ...