Android 5.0+ 解析(八)AppBarLayout控件
来源:互联网 发布:身体域网络的作用范围 编辑:程序博客网 时间:2024/04/28 09:30
AppBarLayout简单介绍
AppBarLayout 是继承LinerLayout实现的一个ViewGroup容器组件,它是为了Material Design设计的App Bar,支持手势滑动操作(需要跟CoordinatorLayout配合使用,下面会介绍如何配合CoordinatorLayout组件)。默认的AppBarLayout是垂直方向的,它的作用是把AppBarLayout包裹的内容都作为AppBar。
AppBarLayout + CoordinatorLayou实现滑动和悬停的tab布局
<span style="font-size:18px;"><?xml version="1.0" encoding="utf-8"?><android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <android.support.v7.widget.Toolbar android:id="@+id/third_activity_toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"/> <android.support.design.widget.TabLayout android:id="@+id/tab_layout" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_scrollFlags="scroll|enterAlways" app:tabIndicatorColor="@color/medium_blue" app:tabSelectedTextColor="@color/medium_blue" app:tabTextAppearance="@style/TabText" app:tabTextColor="@color/gray_text"/> </android.support.design.widget.AppBarLayout> <android.support.v4.view.ViewPager android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_behavior="@string/appbar_scrolling_view_behavior"/></android.support.design.widget.CoordinatorLayout></span>1、在AppBarLayout里面的View,通过app:layout_scrollFlags属性来控制,滚动时候的表现.其中有4种Flag的类型:
scroll: this flag should be set for all views that want to scroll off the screen - for views that do not use this flag, they’ll remain pinned to the top of the screen
enterAlways: this flag ensures that any downward scroll will cause this view to become visible, enabling the ‘quick return’ pattern
enterAlwaysCollapsed: When your view has declared a minHeight and you use this flag, your View will only enter at its minimum height (i.e., ‘collapsed’), only re-expanding to its full height when the scrolling view has reached it’s top.
exitUntilCollapsed: this flag causes the view to scroll off until it is ‘collapsed’ (its minHeight) before exiting
(上面的例子种用的是 scroll 和 enterAlways.)
Scroll 表示向下滚动时,这个View会被滚出屏幕范围直到隐藏.
enterAlways 表示向上滚动时,这个View会随着滚动手势出现,直到恢复原来的位置.
2、 在可以滚动的View上设置属性 app:layout_behavior.
该属性的值实际上是一个完整的class名字,而上面例子中的 @string/appbar_scrolling_view_behavior 是Android Support Library 定义后的值,可以被直接使用.
这个Behavior的class是真正控制滚动时候View的滚动行为.我们也可以继承Behavior这个class去实现特有的滚动行为.
注意: 如果AppBarLayout与Toolbar一起使用,其必须作为Toolbar的父布局容器
欢迎留言和评论!
博客地址:http://blog.csdn.net/caihongdao123下一篇 Android 5.0+ 解析(九)TabLayout控件
5 0
- Android 5.0+ 解析(八)AppBarLayout控件
- android新控件AppBarLayout,
- Android M新控件之AppBarLayout,CoordinatorLayout
- android 控件 隐藏toolbar-(CoordinatorLayout Toolbar AppbarLayout)
- ANDROID AppBarLayout
- Android 5.0新控件 AppBarLayout | 嵌套布局 介绍及使用详情
- Android Design AppBarLayout、NavigationView、FloatingActionButton、CollapsingToolbarLayout等控件的使用
- MD控件(一) AppBarLayout
- android 界面滑动隐藏(CoordinatorLayout+AppBarLayout)
- CoordinatorLayout和AppBarLayout(android MD 三)
- Android学习(八)AutoCompleteTextView控件
- Android 5.0+ 解析(二)CardView控件
- Android 5.0+ 解析(四)Toolbar控件
- Android 5.0+ 解析(五)FloatingActionButton控件
- Android 5.0+ 解析(六)TextInputLayout控件
- Android 5.0+ 解析(七)Snackbar控件
- AppBarLayout控件 & CoordinatorLayout 控件 详解
- Android CoordinatorLayout + AppBarLayout
- mybatis3 集成ehcache
- 第十六周实践项目之阅读程序————9
- 判断网站的好坏的三大标准
- Bootstrap进度条
- Mysql----学习笔记
- Android 5.0+ 解析(八)AppBarLayout控件
- 什么是Boot Loader
- 贡献一组摘自快递100的物流数据 哪位有改造成plist记得私信告诉我
- 第3章 服务框架
- 数独小游戏
- spark RDD的5个重要内部属性
- 没有庸俗的企业,只有不停的战场
- python---学习链接
- mybatis批量插入