AppBarLayout+ToolBar+CollapsingToolbarLayout+NestedScrollView

本文介绍了AppBarLayout作为AppBar的容器,它需要依赖CoordinatorLayout,并与ToolBar和CollapsingToolbarLayout配合使用。ToolBar是Material Design风格的导航控件,允许自定义布局并设置导航图标、Logo等。CollapsingToolbarLayout提供了可折叠的Toolbar效果,常用于AppbarLayout中。NestedScrollView则是一个支持嵌套滑动的滚动视图,扩展了ScrollView的功能。
摘要由CSDN通过智能技术生成

AppBarLayout:
AppBarLayout是继承LinearLayout的子类,根据名称可以知道它是AppBar的容器。

AppBarLayout需要注意几点:

  • 让子View可以选择自己的滑动的方式。
  • 需要依赖CoordinatorLayout作为父容器,同时也要求一个具有可以独立滚动的兄弟节点(或兄弟节点的子view可以滚动)才能发挥其功能。

AppBarLayout一般经常与ToolBar和CollapsingToolbarLayout一起使用。

ToolBar:

ToolBar是android 与Android 5.0开始推出的Material Design风格的导航控件,用来取代ActionBar。tionBar相比,Toolbar明显灵活多了,它不像ActionBar一样固定在Activity的顶部,而是可以放在界面的任意地方。并且ToolBar可以有很多定制的余地,定制的属性在API文档中都有详细的介绍。

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/activity_tool_bar_app_bar"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/PoPupMenu">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="控件"/>

    </android.support.v7.widget.Toolbar>

<
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值