CollapsingToolbarLayout + Palette

本文介绍了Android中的CollapsingToolbarLayout组件,它允许创建滑动的Toolbar并展示自定义布局。CollapsingToolbarLayout配合CoordinatorLayout的Behavior实现复杂交互。同时,文章讲解了Palette组件的使用,通过分析图片色彩来改变Toolbar的颜色,如设置为状态栏颜色,以达到和谐统一的视觉效果。
摘要由CSDN通过智能技术生成

一、CollapsingToolbarLayout

Android中的这个组件,是滑动的Toolbar,且Toolbar里面可以显示自定义的布局。它主要用于两个方面:
1、当做普通的FrameLayout作为根布局使用
2、作为一个或者多个子View进行复杂交互的容器
CoordinatorLayout 为我们提供了一个叫做Behavior的东西,我们基本上的复杂交互都是使用Behavior来协调完成。

示例如下:
(1)添加依赖包 implementation 'com.android.support:design:28.0.0'
(2)界面布局 其中的资源文件自己可以随便在网上找些。

<?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:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+i
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值