参考文档

  1. CoordinatorLayout 完全解析
    1.1 关于NestedScrollingParent2、NestedScrollingChild2接口目的 支持滑动嵌套类的父布局 这篇文的demo挺好的
    1.2 提供一个顶层布局来支持子View的协调交互,就完全解析里的floating样例很经典。
    1.3 CoordinatorLayout和RecyclerView嵌套滑动冲突解决
    1)对内部嵌套的横向滑动的RecyclerView 设置setNestedScrollingEnabled很好用 可以解滑动冲突,包括收起了的CoordinatorLayout margintop也拉不下来 贼好用
    2)如果CollapsingToolbarLayout嵌套ConstrLayout会一起上移,ToolBar会固定住,CoordinatorLayout 能力有限,具体的还得自己做动画
    3)AppLayoutBar和不动的ToolBar结合,偏移量会到ToolBar为止,下级依赖的高度不能比AppBarLayout大(不然收到的偏移量为0),实测相等是可以的
    4)NestedScrollView高度必须要match_parent 不然影响上浮效果;
    5)Activity的手势gesture可以不受影响,onTouchEvent会被拦截;
    6)addOnOffsetChangedListener 设一个匿名对象remove时不好处理,但可以传this 以activity为实现对象,移除移this即可;
    7)学习CoordinatorLayout你需要知道的那些事
  2. [CollapsingToolbarLayout说明] 可以实现折叠
    2.1 他没有自带的监听,可以手动写监听,根据距离判断展开/收起

    2.1 AppBarLayout:ToolBar一般定在最上面,这个可以使其滚动起来。

1. 初级样例传送门

  1. CollapsingToolbarLayout
  2. View - AppBarLayout(一)使用
  3. Android 详细分析AppBarLayout的五种ScrollFlags
  4. CollapsingToolbarLayout滑动状态监听
  5. CollapsingToolbarLayout实现自动折叠和展开
    5.1 可设置动画,但是boolean类型
    5.2 AppbarLayout最详细使用说明
  6. 内嵌view
  7. 利用 CollapsingToolbarLayout 完成联动的动画效果 结合距离公式

2. 细节注意

  1. androidx.coordinatorlayout.widget.CoordinatorLayout(协调者布局)包裹的内容
  2. AppBarLayout如果我们想要实现折叠的ActionBar效果
  3. CollapsingToolbarLayout主要是实现折叠布局的,需要作为AppBarLayout的子View才会有效
  4. AppbarLayout的简单用法
  5. 简单结构
oordinatorLayout orientation="vertical mmAppBarLayout mhCollapsingToolbarLayout mm app:layout_scrollFlags="scroll|exitUntilCollapsed"ConstraintLayout mm


7. 其余各种属性详解
1)contentScrim
当CollapsingToolbarLayout完全折叠后的背景颜色。
通常设置为:app:contentScrim=”?attr/colorPrimary”,这样当CollapsingToolbarLayout完全折叠后就会显示主题颜色。
2)layout_scrollFlags:
设置滚动表现:
1、 Scroll, 表示手指向上滑动的时候,CollapsingToolbarLayout也会向上滚出屏幕并且消失,这个属性必须要有。
2、 exitUntilCollapsed, 表示这个layout会一直滚动离开屏幕范围,直到它收折成它的最小高度.
8. 补充B站例子

修改Floating颜色

  1. 核心代码:
ColorStateList colorStateList = ContextCompat.getColorStateList(getApplicationContext(), R.color.red;
fabRandomCircle.setBackgroundTintMode(PorterDuff.Mode.SRC_ATOP);
fabRandomCircle.setBackgroundTintList(colorStateList);
  1. 不错的思路补充

加入Palette,一定要看

1. 安卓自带的Palette,需要Bitmap

1.5 补充

2. 操作

1.当一张图色彩区域不是很明显 设置默认颜色是有效的 如飞鼠

  1. 默认红色

  2. 默认蓝色

  1. 经过多张图片测试 主导色最好用 且测试发现 如果设置默认值的方式 返回的一定是颜色值,不传递默认值 返回的是Palette.Swatch对象。这个对象的方法很好用

class MainActivity : AppCompatActivity() {var t1: TextView? = nullvar t2: TextView? = nullvar t3: TextView? = nullvar t4: TextView? = nullvar t5: TextView? = nullvar t6: TextView? = nullvar t7: TextView? = nulloverride fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)t1 = findViewById<View>(R.id.t1) as TextViewt2 = findViewById<View>(R.id.t2) as TextViewt3 = findViewById<View>(R.id.t3) as TextViewt4 = findViewById<View>(R.id.t4) as TextViewt5 = findViewById<View>(R.id.t5) as TextViewt6 = findViewById<View>(R.id.t6) as TextViewt7 = findViewById<View>(R.id.t7) as TextViewval bitmap = BitmapFactory.decodeResource(resources, R.drawable.mouse)Palette.from(bitmap).generate(object : Palette.PaletteAsyncListener {//发生主线程    Palette调色板   总共六种颜色override fun onGenerated(palette: Palette?) {palette?.let {//柔和而暗的颜色val darkMutedColor: Int = palette.getDarkMutedColor(Color.RED)//鲜艳和暗的颜色val darkVibrantColor: Int = palette.getDarkVibrantColor(Color.RED)//亮和鲜艳的颜色val lightVibrantColor: Int = palette.getLightVibrantColor(Color.RED)//亮和柔和的颜色val lightMutedColor: Int = palette.getLightMutedColor(Color.RED)//柔和颜色val mutedColor: Int = palette.getMutedColor(Color.RED)val vibrantColor: Int = palette.getVibrantColor(Color.RED)//返回Swatch主导颜色val max: Palette.Swatch? = palette.dominantSwatcht1!!.setBackgroundColor(darkMutedColor)t2!!.setBackgroundColor(darkVibrantColor)t3!!.setBackgroundColor(lightVibrantColor)t4!!.setBackgroundColor(lightMutedColor)t5!!.setBackgroundColor(mutedColor)t6!!.setBackgroundColor(vibrantColor)if (max != null) {t7!!.setBackgroundColor(max.rgb)t7!!.setTextColor(max.titleTextColor)}}}})}
}

【Android+Kotlin】自适应CoordinatorLayout,AppBarLayout,CollapsingToolbarLayout与Palette相关推荐

  1. Android之解决CoordinatorLayout+AppBarLayout+CollapsingToolbarLayout+RecyclerView里面再嵌套RecyclerView滑动颤抖问题

    1 问题 主页面用的是这种结构 CoordinatorLayout+AppBarLayout+CollapsingToolbarLayout+RecyclerView(里面再嵌套RecyclerVie ...

  2. CoordinatorLayout+AppBarLayout+CollapsingToolbarLayout+Toolbar组合悬浮置顶的效果

    最近由于公司业务需求的增加,产品部门给了一个新功能 类似于掌上英雄联盟的效果,但是实际功能比掌上英雄联盟要多,可以看一下掌上英雄联盟的效果.效果图如下: 我们产品的功能需求是,当向上滑动的时候名称呈渐 ...

  3. CoordinatorLayout/AppbarLayout/CollapsingToolbarLayout的配合使用,Toolbar特效

    上面这个特效就是Toolbar与CoordinatorLayout/AppbarLayout/CollapsingToolbarLayout配合后的效果:这几个View单独使用没什么效果,一般都是要互 ...

  4. #Android笔记# 超级足球app 开发总结(三)—— CoordinatorLayout+AppBarLayout+CollapsingToolbarLayout实现两种折叠效果

    最近利用业余时间,开发了一款基于懂球帝接口数据的足球资讯app,整体的UI也是仿照懂球帝设计的.这是一个比较综合的项目,用到了不少以前没用过的组件和api,而且产生了很多新的开发思路,有些实现方式也是 ...

  5. CoordinatorLayout+AppBarLayout+CollapsingToolbarLayout+Toolbar实现渐变透明的状态栏

    在之前的一篇博文里面我已经说明了CoordinatorLayout使用过程中遇到的问题,之后又发现结合CollapsingToolbarLayout使用时的另一个问题.CollapsingToolba ...

  6. CoordinatorLayout + AppBarLayout + CollapsingToolbarLayout

    CoordinatorLayout CoordinatorLayout相当于一个功能更加强大的FrameLayout,主要有两个用途: 作为顶层布局: 作为协调与子布局之间交互的容器. 通过为子布局指 ...

  7. 纯享版-Android AppBarLayout + CollapsingToolbarLayout丝滑自动折叠、吸顶

    使用CoordinatorLayout+AppBarLayout+CollapsingToolbarLayout+TabLayout+ViewPager,实现tab滑动吸顶效果简直完爆ScrollVi ...

  8. coordinatorlayout_一篇文章学会Coordinatorlayout+AppbarLayout

    点击上方蓝字关注 ?? 来源:  奔跑吧李博 https://www.jianshu.com/p/cd93da2b7a24 前言 现如今,折叠式布局在App中相当常见,给人一种科技感,充满良好的用户体 ...

  9. 【转】Android M新控件之AppBarLayout,NavigationView,CoordinatorLayout,CollapsingToolbarLayout的使用...

    Android M新控件之AppBarLayout,NavigationView,CoordinatorLayout,CollapsingToolbarLayout的使用 分类: Android UI ...

  10. android 上滑隐藏view,Android CoordinatorLayout + AppBarLayout(向上滚动隐藏指定的View)

    在新的Android Support Library里面,新增了CoordinatorLayout, AppBarLayout等. 实现的效果: 向下滚动RecylerView,Tab会被隐藏,向上滚 ...

最新文章

  1. linux发送email错误 501 Syntax: HELO hostname
  2. MySQL优化篇:数据准备
  3. Ubuntu8.10安装Netbeans6.7中文乱码解决方案
  4. SQLServer2014 安装错误:等待数据库引擎恢复句柄失败
  5. python 判断当前系统的Python编译器类型
  6. python黑网站_Python简单实现HTTP本地代理转发
  7. CentOS系统里如何正确取消或者延长屏幕保护自动锁屏功能(图文详解)
  8. [转]VC _T的用途
  9. 教你分分钟学会用python爬虫框架Scrapy爬取心目中的女神
  10. Protobuf 判断某个值是否在一个枚举值中
  11. git不能上传空目录和设备文件
  12. Apache(阿帕奇)Web服务器的安装和使用
  13. 2021-07-21
  14. 【IoT】产品设计之市场概念:市场定位、产品定位、市场需求、产品需求
  15. 知识图谱架构(Knowledge Graph)
  16. python提取数列数字_从pandas datafram中的列中提取字符串中的数字
  17. 服务器测评文档,十年磨一剑,腾讯自研TBase数据库有奖测评
  18. java鬼吹灯搬山法杖_鬼吹灯昆仑神宫技能搭配攻略之搬山职业篇
  19. mysql主从skip1677_mysql主从复制部署
  20. 【科研绘图】PS绘制封面中神奇的放大效果

热门文章

  1. Jmeter的Html报告汉化及解析
  2. [极致用户体验] 网页里的「返回」应该用 history.back 还是 push ?
  3. 从北京到新加坡再到阿姆斯特丹,他去公布了一个惊天的“秘密”
  4. NLP「自然语言处理技术」
  5. LIME Low light Image Enhancement via Illumination Map Estimation
  6. 【Scratch画图100例】图39-scratch实心圆 少儿编程 scratch编程画图案例教程 考级比赛画图集训案例
  7. UE4之添加开场动画
  8. 机械祭天法力无边:练习3.6:编写一段程序,使用范围for语句将字符串内的所有字符用X代替。
  9. vue + 生成 下载 成 二维码
  10. 渗透测试神器之metasploit