如何使回收站视图不滚动时appbar卡扣 [英] How to make Recycler View not scroll when appbar snaps

查看:410
本文介绍了如何使回收站视图不滚动时appbar卡扣的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我所做的捕捉应用栏是这样的:

I have made the snapping app bar like this:

请注意,当滚动,中间留(即标题是成功的一半可见的,那么应用栏自动对齐)

Please note that when the scroll is left in the middle(i.e the title is half visible, then the app bar snaps automatically)

在谷歌的发挥这种情况下是捕捉如下:

In case of google play this is what the snap looks like:

现在,我要捕捉到像在谷歌播放工作。这是当捕捉发生时,则只有应用程序栏应捕捉和回收视图不能移动。它会更好,如果解决方案支持的pre棒棒糖设备了。

Now, I want the snap to work like the one in google play. Which is that when the snap occurs, then only the app bar should snap and the recycler view should not move. It would be better if the solution supported pre lollipop devices too.

谢谢!

推荐答案

我发现,在我的项目工作的很好的解决方案。它由2行为,一个用于AppBarLayout和另一个用于滚动容器。你可以找到它在Github这里: appbar-单元的行为

I found a solution that works quite well in my project. It consists of 2 behaviors, one for the AppBarLayout and another one for the scrolling container. You can find it on Github here: appbar-snap-behavior

这是很容易进行安装:

compile "com.github.godness84:appbar-snap-behavior:0.1.1"

记住要添加行家{URLhttps://jitpack.io} 在库后,你的根的build.gradle:

Remember to add maven { url "https://jitpack.io" } in your root build.gradle at the end of repositories:

allprojects {
        repositories {
            ...
            maven { url "https://jitpack.io" }
        }
}

然后:


  1. 添加应用:layout_behavior =com.github.godness84.appbarsnapbehavior.AppBarSnapBehavior您AppBarLayout

  2. 使用应用:layout_behavior =com.github.godness84.appbarsnapbehavior.ScrollingViewBehavior到您的滚动容器

  1. add app:layout_behavior="com.github.godness84.appbarsnapbehavior.AppBarSnapBehavior" to your AppBarLayout
  2. use app:layout_behavior="com.github.godness84.appbarsnapbehavior.ScrollingViewBehavior" into your scrolling container.

不幸的是,由于AppBarLayout的默认行为被替换,某些功能不可用了(比如 AppBarLayout.setExpanded()的),但在的正常的情况下,它作品!给它一个尝试,让我知道。

Unfortunately, since the default behavior of the AppBarLayout is replaced, some features are not available anymore (for example AppBarLayout.setExpanded()), but in normal situations it works! Give it a try and let me know.

这篇关于如何使回收站视图不滚动时appbar卡扣的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆