前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >专栏 >CoordinatorLayout与滚动的处理

CoordinatorLayout与滚动的处理

作者头像
小小工匠
发布于 2021-08-16 02:20:59
发布于 2021-08-16 02:20:59
82900
代码可运行
举报
文章被收录于专栏:小工匠聊架构小工匠聊架构
运行总次数:0
代码可运行

本博文专门讲解和CoordinatorLayout相关的知识点,这也是Design Support Library中最重要与最难的部分。


概览

CoordinatorLayout实现了多种Material Design中提到的滚动效果。目前这个框架提供了几种不用写动画代码就能工作的方法,这些效果包括:

让浮动操作按钮上下滑动,为Snackbar留出空间

扩展或者缩小Toolbar或者头部,让主内容区域有更多的空间。

控制哪个view应该扩展还是收缩,以及其显示大小比例,包括视差滚动效果parallax scrolling effects 动画。


Code Samples

官方为我们提供了一个漂亮的demo ,使用了 CoordinatorLayout 和其他的 design support library特性.

详情请查看github

效果图

Setup

Make sure to follow the Design Support Library instructions first.

Floating Action Buttons and Snackbars

The CoordinatorLayout can be used to create floating effects using the layout_anchor and layout_gravity attributes. See the Floating Action Buttons guide for more information.

When a Snackbar is rendered, it normally appears at the bottom of the visible screen. To make room, the floating action button must be moved up to provide space.

So long as the CoordinatorLayout is used as the primary layout, this animation effect will occur for you automatically. The floating action button has a default behavior that detects Snackbar views being added and animates the button above the height of the Snackbar.

Code

activity_fab__snackar.xml

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
"1.0" encoding="utf-8"?>
.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    .support.v7.widget.RecyclerView
        android:id="@+id/rvToDoList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>



    .support.design.widget.FloatingActionButton
        android:id="@+id/floatingActionButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:layout_margin="16dp"
        android:src="@drawable/gur_project_10"
        app:layout_anchor="@id/rvToDoList"
        app:layout_anchorGravity="bottom|right|end"
        app:layout_behavior="demo.turing.com.materialdesignwidget.floatingActionButton.ScrollAwareFABBehavior"/>

.support.design.widget.CoordinatorLayout>

Fab_SnackarAct.java

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
public class Fab_SnackarAct extends AppCompatActivity {

    private RecyclerView recyclerView;
    private FloatingActionButton floatingActionButton;
    private CoordinatorLayout coordinatorLayout ;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fab__snackar);

        coordinatorLayout = (CoordinatorLayout) findViewById(R.id.main_content);

        floatingActionButton = (FloatingActionButton) findViewById(R.id.floatingActionButton);

        recyclerView = (RecyclerView) findViewById(R.id.rvToDoList);

        // 线性布局
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        // 设置适配器,填充数据
        recyclerView.setAdapter(new NormalRecyclerViewAdapter(this));


        floatingActionButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view,"HELLO",Snackbar.LENGTH_SHORT).show();
            }
        });
    }
}

关键点

  • 根布局必须为CoordinatorLayout
  • FloatingActionButton设置 app:layout_anchor和app:layout_anchorGravity属性
  • app:layout_behavior这个属性也可以不加也能实现点击floatingActionButton弹出Snackbar,fab自动上移的效果,app:layout_behavior的为自定义的效果,当下滑时,fab消失,上滑时fab显示,详情请查看本人博客 Floating Action Button-Android M新控件

运行图


Expanding and Collapsing Toolbars(Toolbar的扩展与收缩)

  • The first step is to make sure you are not using the deprecated ActionBar. Make sure to follow the Using the ToolBar as ActionBar guide.
  • Also make sure that the CoordinatorLayout is the main layout container.
代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

      .support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

.support.design.widget.CoordinatorLayout>

Responding to Scroll Events

Next, we must make the Toolbar responsive to scroll events using a container layout called AppBarLayout: 接下来,我们必须使用一个容器布局:AppBarLayout来让Toolbar响应滚动事件。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/detail_backdrop_height"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:fitsSystemWindows="true">

  .support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

 .support.design.widget.AppBarLayout>

Note: AppBarLayout currently expects to be the first child nested within a CoordinatorLayout according to the official Google docs. 注意:根据官方的谷歌文档,AppBarLayout目前必须是第一个嵌套在CoordinatorLayout里面的子view。

Next, we need to define an association between the AppBarLayout and the View that will be scrolled. Add an app:layout_behavior to a RecyclerView or any other View capable of nested scrolling such as NestedScrollView 。 The support library contains a special string resource @string/appbar_scrolling_view_behavior that maps to AppBarLayout.ScrollingViewBehavior, which is used to notify the AppBarLayout when scroll events occur on this particular view. The behavior must be established on the view that triggers the event.

然后,我们需要定义AppBarLayout与滚动视图之间的联系。在RecyclerView或者任意支持嵌套滚动的view比如NestedScrollView上添加app:layout_behavior。support library包含了一个特殊的字符串资源@string/appbar_scrolling_view_behavior,它和AppBarLayout.ScrollingViewBehavior相匹配,用来通知AppBarLayout 这个特殊的view何时发生了滚动事件,这个behavior需要设置在触发事件(滚动)的view之上。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
.support.v7.widget.RecyclerView
        android:id="@+id/rvToDoList"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

当CoordinatorLayout发现RecyclerView中定义了这个属性,它会搜索自己所包含的其他view,看看是否有view与这个behavior相关联。AppBarLayout.ScrollingViewBehavior描述了RecyclerView与AppBarLayout之间的依赖关系。RecyclerView的任意滚动事件都将触发AppBarLayout或者AppBarLayout里面view的改变。

AppBarLayout里面定义的view只要设置了app:layout_scrollFlags属性,就可以在RecyclerView滚动事件发生的时候被触发:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
 .support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            .support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_scrollFlags="scroll|enterAlways"/>

 .support.design.widget.AppBarLayout>

app:layout_scrollFlags属性里面必须至少启用scroll这个flag,这样这个view才会滚动出屏幕,否则它将一直固定在顶部。可以使用的其他flag有:

  • enterAlways: 一旦向上滚动这个view就可见。

Normally, the Toolbar only appears when the list is scrolled to the top as shown below:

  • enterAlwaysCollapsed: 顾名思义,这个flag定义的是何时进入(已经消失之后何时再次显示)。假设你定义了一个最小高度(minHeight)同时enterAlways也定义了,那么view将在到达这个最小高度的时候开始显示,并且从这个时候开始慢慢展开,当滚动到顶部的时候展开完。
  • exitUntilCollapsed: 同样顾名思义,这个flag时定义何时退出,当你定义了一个minHeight,这个view将在滚动到达这个最小高度的时候消失。
  • snap:Using this option will determine what to do when a view only has been partially reduced. If scrolling ends and the view size has been reduced to less than 50% of its original, then this view to return to its original size. If the size is greater than 50% of its sized, it will disappear completely.

记住,要把带有scroll flag的view放在前面,这样收回的view才能让正常退出,而固定的view继续留在顶部。

此时,你应该注意到我们的Toolbar能够响应滚动事件了。


Creating Collapsing Effects(制造折叠效果)

如果想制造toolbar的折叠效果,我们必须把Toolbar放在CollapsingToolbarLayout中:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginEnd="64dp"
            app:expandedTitleMarginStart="48dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            .support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_scrollFlags="scroll|enterAlways">.support.v7.widget.Toolbar>

.support.design.widget.CollapsingToolbarLayout>

现在效果就成了:

通常,我们我们都是设置Toolbar的title,而现在,我们需要把title设置在CollapsingToolBarLayout上,而不是Toolbar。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
CollapsingToolbarLayout collapsingToolbar =
              (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
      collapsingToolbar.setTitle("Title");

Note that when using CollapsingToolbarLayout, the status bar should be made translucent (API 19) or transparent (API 21) as shown in this file. In particular, the following styles should be set in res/values-xx/styles.xml as illustrated:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<style name="AppTheme" parent="Base.AppTheme">
    <item name="android:windowTranslucentStatus">trueitem>
style>


<style name="AppTheme" parent="Base.AppTheme">
    <item name="android:windowDrawsSystemBarBackgrounds">trueitem>
    <item name="android:statusBarColor">@android:color/transparent
style>

Creating Parallax Animations(制造视差效果)

CollapsingToolbarLayout还能让我们做出更高级的动画,比如在里面放一个ImageView,然后在它折叠的时候渐渐淡出。同时在用户滚动的时候title的高度也会随着改变。

为了制造出这种效果,我们添加一个定义了app:layout_collapseMode=”parallax” 属性的ImageView。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
 .support.design.widget.CollapsingToolbarLayout
          android:id="@+id/collapsing_toolbar"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:fitsSystemWindows="true"
          app:contentScrim="?attr/colorPrimary"
          app:expandedTitleMarginEnd="64dp"
          app:expandedTitleMarginStart="48dp"
          app:layout_scrollFlags="scroll|exitUntilCollapsed">

          .support.v7.widget.Toolbar
              android:id="@+id/toolbar"
              android:layout_width="match_parent"
              android:layout_height="?attr/actionBarSize"
              app:layout_scrollFlags="scroll|enterAlways">.support.v7.widget.Toolbar>
          "@drawable/cheese_1"
              app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:scaleType="centerCrop"
              app:layout_collapseMode="parallax"
              android:minHeight="100dp"/>

      .support.design.widget.CollapsingToolbarLayout>

Custom Behaviors (自定义Behavior)

CoordinatorLayout 与浮动操作按钮中我们讨论了一个自定义behavior的例子。 译文http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0718/3197.html

CoordinatorLayout的工作原理是搜索定义了CoordinatorLayout Behavior 的子view,不管是通过在xml中使用app:layout_behavior标签还是通过在代码中对view类使用@DefaultBehavior修饰符来添加注解。当滚动发生的时候,CoordinatorLayout会尝试触发那些声明了依赖的子view。

要自己定义CoordinatorLayout Behavior,你需要实现layoutDependsOn() 和onDependentViewChanged()两个方法。比如AppBarLayout.Behavior 就定义了这两个关键方法。这个behavior用于当滚动发生的时候让AppBarLayout发生改变。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
          return dependency instanceof AppBarLayout;
      }

 public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
          // check the behavior triggered
          android.support.design.widget.CoordinatorLayout.Behavior behavior = ((android.support.design.widget.CoordinatorLayout.LayoutParams)dependency.getLayoutParams()).getBehavior();
          if(behavior instanceof AppBarLayout.Behavior) {
          // do stuff here
          }
 }      

英文原文:

https://guides.codepath.com/android/Handling-Scrolls-with-CoordinatorLayout

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2016/03/09 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
CoordinatorLayout使用(四):和Toolbar的简单使用
这篇也就简单使用,和前面关系不大 就暂时不复习了 这篇可能有点啰嗦,并且只是使用,没有难度 熟悉的同学略过前面,或者整篇略过
dodo_lihao
2018/09/12
1.5K0
CoordinatorLayout使用(四):和Toolbar的简单使用
Android--AppBarLayout、CollapsingToolbarLayout组合使用
通常AppBarLayout和CollapsingToolbarLayout是一起使用的,也就是CoordinatorLayout、AppBarLayout、CollapsingToolbarLayout、Toolbar常常是组合应用的,AppBarLayout能够赋予Toolbar显示和消失的功能,而CollapsingToolbarLayout能够赋予Toolbar伸缩的功能 AppBarLayout下只能有一个控件,而CollapsingToolbarLayout需要包裹Toolbar外,还支持包裹其
aruba
2020/07/03
3.6K0
Android--AppBarLayout、CollapsingToolbarLayout组合使用
高仿支付宝9.9.2版本生活模块界面来讲解CoordinatorLayout,AppBarLayout,CollapsingToolbarLayout
是不是很像支付宝的效果呢,我们今天就要通过讲解android5.0新出的控件CoordinatorLayout,AppBarLayout,CollapsingToolbarLayout来实现这个效果。
HelloJack
2018/08/28
1.2K0
高仿支付宝9.9.2版本生活模块界面来讲解CoordinatorLayout,AppBarLayout,CollapsingToolbarLayout
CoordinatorLayout打造折叠式的顶部标题栏
如果以上简单操作无法满足你的需求,最后附上参考博客文章 Android开发之CoordinatorLayout打造滑动越界弹性放大图片效果 使用CoordinatorLayout打造各种炫酷的效果
木溪bo
2018/12/27
2.1K0
自定义Behavior —— 仿知乎,FloatActionButton隐藏与展示
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/gdutxiaoxu/article/details/53453958
程序员徐公
2018/09/18
1.1K0
自定义Behavior —— 仿知乎,FloatActionButton隐藏与展示
Android开发笔记(一百三十六)可折叠工具栏布局CollapsingToolbarLayout
上一篇博文《Android开发笔记(一百三十五)应用栏布局AppBarLayout》阐述了如何把Toolbar往上滚动,那反过来,能不能把Toolbar往下拉动呢?这里要明确一点,Toolbar本身是页面顶部的工具栏,其上没有本页面的其它控件了,如果Toolbar被拉下来了,那Toolbar上面的空白该显示什么?所以Toolbar的上部边缘是不可以往下拉的,只有下部边缘才能往下拉,这样的视觉效果好比Toolbar如电影幕布一般缓缓向下展开。 不过,Android在实现展开效果的时候,并非直接让Toolbar展开或收缩,而是另外提供了CollapsingToolbarLayout,通过该布局包裹Toolbar,从而控制标题栏的展开和收缩行为。下面是CollapsingToolbarLayout的属性说明: app:contentScrim : 指定布局内部未展开时的背景颜色。 app:collapsedTitleTextAppearance : 指定未展开时的标题文字字体。 app:collapsedTitleTextColor : 指定未展开时的标题文字颜色。 app:collapsedTitleGravity : 指定未展开时的标题文字对齐方式。 app:expandedTitleTextAppearance : 指定展开后的标题文字字体。 app:expandedTitleTextColor : 指定展开后的标题文字颜色。 app:expandedTitleGravity : 指定展开后的标题文字对齐方式。 app:expandedTitleMargin : 指定展开后的标题四周间距。 app:expandedTitleMarginStart/app:expandedTitleMarginTop/app:expandedTitleMarginEnd/app:expandedTitleMarginBottom : 指定展开后的标题具体方向的间距。 上述属性在代码中的设置方法如下所示: setContentScrim/setContentScrimColor/setContentScrimResource : 设置布局内部未展开时的背景颜色。 setCollapsedTitleTextAppearance : 设置未展开时的标题文字字体。 setCollapsedTitleTextColor : 设置未展开时的标题文字颜色。 setCollapsedTitleGravity : 设置未展开时的标题文字对齐方式。 setExpandedTitleTextAppearance : 设置展开后的标题文字字体。 setExpandedTitleColor : 设置展开后的标题文字颜色。 setExpandedTitleGravity : 设置展开后的标题文字对齐方式。 setExpandedTitleMargin : 设置展开后的标题四周间距。 setExpandedTitleMarginStart/setExpandedTitleMarginTop/setExpandedTitleMarginEnd/setExpandedTitleMarginBottom : 设置展开后的标题具体方向的间距。 在工程中使用CollapsingToolbarLayout,则需注意以下几点: 1、添加几个库的支持,包括appcompat-v7库(Toolbar需要)、design库(CollapsingToolbarLayout需要)、recyclerview库(主页面的RecyclerView需要); 2、布局文件的根布局采用android.support.design.widget.CoordinatorLayout,因为design库的动态效果都依赖于该控件; 3、CoordinatorLayout节点要添加命名空间声明xmlns:app="http://schemas.android.com/apk/res-auto"; 4、使用android.support.design.widget.AppBarLayout节点包裹android.support.design.widget.CollapsingToolbarLayout节点,再在CollapsingToolbarLayout节点下添加Toobar; 5、Toobar节点添加滚动属性app:layout_scrollFlags="scroll|enterAlways",声明工具栏的滚动行为标志; 其实真正运行的时候,Toolbar的高度是固定不变的,变化高度的是CollapsingToolbarLayout。只是许多App把这两者的背景设为一样的,所以看起来像是统一的标题栏在收缩和展开。既然二者原本不是一家,那么就得有新的属性用于区分它们内部的行为,新属性在Collaps
aqi00
2019/01/18
3.4K0
Android材料设计之AppBarLayout+CoordinatorLayout
零、前言: AppBarLayout+CoordinatorLayout:废话不多说,Material Design还是用图说话 1.scroll:首子控件吸顶:app:layout_scrollFlags="scroll" 2.exitUntilCollapsed:首子控件半吸顶:app:layout_scrollFlags="scroll|exitUntilCollapsed"+minHeight 3.enterAlways:首子控件吸顶+首子控件先下滑:app:layout_scrollF
张风捷特烈
2018/12/19
2.1K0
一个Demo学会用Android兼容包新控件
伟大的Google为Android推出了一系列的兼容包,最新的就是Design Support Library了,这里我们结合v7和v4中的几个控件,来主要学习Design Support Library中的几个新控件!一个Demo学会用它们!
GitOPEN
2019/01/29
1.5K0
一个Demo学会用Android兼容包新控件
AppBarLayout学习
AppBarLayout是一个垂直的LinearLayout,实现了很多和协调布局一起合作的滚动属性。其子View可以通过setScrollFlags()或在xml布局中通过app:layout_scrollFlags属性设置想要的滚动行为。
用户1108631
2019/08/17
1.2K0
CoordinatorLayout+AppBarLayout实现上滑隐藏ToolBar-Android M新控件
从官方文档中我们可以看到: CoordinatorLayout是一个增强型的FrameLayout。 两个作用: - As a top-level application decor or chrome layout - As a container for a specific interaction with one or more child views
小小工匠
2021/08/16
2.2K0
细说 AppbarLayout,如何理解可折叠 Toolbar 的定制
Material Design 是个好东西,它的出现使得 Android 也能定制高颜值的界面,并且指导了如果实现复杂炫丽的交互效果,而 Android Surpport Desgin 这个支持包就是 Android 官方对 Material Design 的代码实现。
Frank909
2019/01/14
3.2K1
Android开发笔记(一百三十五)应用栏布局AppBarLayout
Android5.0推出工具栏Toolbar用来替代ActionBar,灵活性和易用性大大增强,有关Toolbar的详细介绍参见《Android开发笔记(一百一十九)工具栏Toolbar》。 可是仅仅使用Toolbar的话,还是有些呆板,比如说Toolbar固定占据着页面顶端,既不能跟着主体页面移上去,也不会跟着主体页面拉下来。为了让App页面更加生动活泼,势必要求Toolbar在某些特定的场景上移或者下拉,如此才能满足酷炫的页面特效需要。那么Android5.0也同时给出了相应的解决方案,即推出MaterialDesign库,通过该库中的AppBarLayout控件,对Toolbar加以包装,从而实现顶部工具栏的动态变化效果。 AppBarLayout其实继承自LinearLayout,所以具备LinearLayout的所有属性与方法。对于大家关心的额外功能,则主要有以下几点: 1、支持响应主体页面的滑动行为,即在主体页面上移或者下拉时,AppBarLayout能够捕捉到主体页面的滚动操作; 2、AppBarLayout捕捉到滚动操作之后,还要通知头部控件(通常是Toolbar),告诉头部控件你要怎么滚,是爱咋咋滚,还是满大街滚; 具体到实现上,要在工程中做以下修改: 1、添加几个库的支持,包括appcompat-v7库(Toolbar需要)、design库(AppBarLayout需要)、recyclerview库(主页面的RecyclerView需要); 2、布局文件的根布局采用android.support.design.widget.CoordinatorLayout,因为design库的动态效果都依赖于该控件; 3、CoordinatorLayout节点要添加命名空间声明xmlns:app="http://schemas.android.com/apk/res-auto"; 4、使用android.support.design.widget.AppBarLayout节点包裹Toobar; 5、Toobar节点添加滚动属性app:layout_scrollFlags="scroll|enterAlways",声明工具栏的滚动行为标志; 6、演示页面的主体页面使用RecyclerView控件,并给该控件节点添加行为属性app:layout_behavior="@string/appbar_scrolling_view_behavior",表示通知AppBarLayout捕捉RecyclerView的滚动操作。 下面是AppBarLayout结合RecyclerView实现的工具栏向上滚动效果截图:
aqi00
2019/01/18
2K0
Android材料设计之Behavior攻坚战
接触目标view时才会回调:onStartNestedScroll 加了layout_behavior的View是child
张风捷特烈
2018/12/21
1.3K0
【Android】这效果,我没法描述
前言 最近接到一个需求,这需求让我表示很尴尬。(下面是一些废话) 要求的效果是这样的,顶部有部分悬浮,接着是一些布局,在下面是几个可切换的Tab页面,然后滚动的时候~~吧啦吧啦吧啦吧啦~~ 还是
Gavin-ZYX
2018/05/18
1K0
用 CoordinatorLayout 处理滚动
原文地址:Handling Scrolls with CoordinatorLayout 原文作者:CODEPATH 译文出自:掘金翻译计划 本文永久链接:github.com/xitu/gold-m… 译者:Feximin 总览 CoordinatorLayout 扩展了完成 Google's Material Design 中的多种滚动效果的能力。目前,此框架提供了几种不需要写任何自定义动画代码就可以(使动画)工作的方式。这些效果包括: 上下滑动 Floating Action Button 以给 Sn
Android 开发者
2018/05/31
4.9K0
Material Design之CollapsingToolbarLayout 相关属性和方法介绍
Material Design之CollapsingToolbarLayout 相关属性和方法介绍
103style
2022/12/19
9850
Material Design之CollapsingToolbarLayout 相关属性和方法介绍
NestedScrollView 嵌套 ListView 实现滑动折叠效果
引言 最近,在做公司一个design折叠效果的时候遇到个问题,就是我们本身app的方法数太多了,dex分包技术还没搞定。不得不尽量缩减一些不必要的包、类。当我们引入RecyclerView的时候,恰好
用户1127566
2018/06/06
3.5K0
MaterialDesign之FloatingActionButton
就是上面这样了,忘说了一件很重要的事情……FloatingActionButton的监听就是最原始的监听!!!接下来到了重头戏了
蜻蜓队长
2018/08/03
7160
MaterialDesign之FloatingActionButton
Material Design 实战 之第四弹 —— 卡片布局
首先这里准备用CardView来填充主题内容, CardView是用于实现卡片式布局效果的重要控件,由appcompat-v7库提供。 实际上,CardView也是一个FrameLayout,只是额外提供了圆角和阴影等效果,看上去会有立体的感觉。
凌川江雪
2018/10/09
2.2K0
Material Design 实战 之第四弹 —— 卡片布局
Material Design 在 Android 中的应用
我刚来这个公司的时候,每个周三都会有分享会,主题自定,分享对象尽量是面向大众,一开始觉得不错,但是到后面发现分享的内容不是那么有营养,而且积极性不是很高,都是当做任务进行分享。 程序员因为较为腼腆,分享的人较少,大部分都是客户部、分析部或者推广部的分享,久而久之,氛围就比较消极。
蜻蜓队长
2018/08/03
1.3K0
Material Design 在 Android 中的应用
推荐阅读
相关推荐
CoordinatorLayout使用(四):和Toolbar的简单使用
更多 >
领券
社区富文本编辑器全新改版!诚邀体验~
全新交互,全新视觉,新增快捷键、悬浮工具栏、高亮块等功能并同时优化现有功能,全面提升创作效率和体验
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文