Android 5.0新控件 CollapsingToolbarLayout | 折叠工具布局 介绍及使用详情

本文介绍了Android 5.0新控件CollapsingToolbarLayout,它是折叠应用栏的实现,包含折叠标题、内容纱幕、状态栏纱幕等功能。详细讲解了其使用方法,包括XML布局、代码设置,并提到了视差滚动和固定子视图等特性。文章提供了完整代码的GitHub下载链接。
摘要由CSDN通过智能技术生成

Android 5.0新控件 CollapsingToolbarLayout | 折叠工具布局 介绍及使用详情

extends FrameLayout

先让我们来看下Google对这个组件的定义(英语好的同学请忽略我的翻译)

CollapsingToolbarLayout is a wrapper for Toolbar which implements a collapsing app bar. It is designed to be used as a direct child of a AppBarLayout.
CollapsingToolbarLayout contains the following features:

CollapsingToolbarLayout 是一个包裹 Toolbar 来实现折叠的app bar.它直接作为AppBarLayout的子View,包含以下功能:

Collapsing title | 折叠标题

A title which is larger when the layout is fully visible but collapses and becomes smaller as the layout is scrolled off screen. You can set the title to display via setTitle(CharSequence).
The title appearance can be tweaked via the collapsedTextAppearance and expandedTextAppearance attributes.

标题哪个更大当布局完全可见但是折叠时和布局滚动关闭屏幕变得更小,你可以通过设置标题通过 setTitle(CharSequence)
标题外观可以通过 CollapsedTitleTextAppearance 和 expandedTieleTextAppearance 来设置

Content scrim | 内容纱幕

A full-bleed scrim which is show or hidden when the scroll position has hit a certain threshold. You can change this via setContentScrim(Drawable).

一个显示或隐藏的纱幕当它滚动到一个指定的阈值,可以设置这个内容纱幕 setContentScrim

Status bar scrim | 状态栏纱幕

A scrim which is show or hidden behind the status bar when the scroll position has hit a certain threshold. You can change this via setStatusBarScrim(Drawable).
This only works on LOLLIPOP devices when we set to fit system windows.

一个显示或隐藏的纱幕当屏幕滚动到指定阈值时的状态栏后面,你可以改变这个状态栏 setStatusBarScrim
这个仅适用于5.0以上的版本并且设置了属性fitSystemWindows 为 true的情况下

Parallax scrolling children | 子View视差滚动

Child views can opt to be scrolled within this layout in a

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值