CollapsingToolbarLayout ImageView的不可滚动 [英] CollapsingToolbarLayout ImageView is not scrollable

本文介绍了CollapsingToolbarLayout ImageView的不可滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 cheesesquare - 支持Android库的例子是有可能使页眉 ImageView的滚动能?

Using cheesesquare - android support library example is it possible to make the Header ImageView scroll-able?

<android.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">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginStart="48dp"
        app:expandedTitleMarginEnd="64dp">

        <ImageView
            android:id="@+id/backdrop"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerCrop"
            android:fitsSystemWindows="true"
            app:layout_scrollFlags="scroll" 
            app:layout_collapseMode="parallax" />
            ...
    </android.support.design.widget.CollapsingToolbarLayout>

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">
    ....

的通知,我已经增加添加安卓fillViewport =真正的 NestedScrollView 添加 应用程序:layout_scrollFlags =滚动来 在的ImageView 而是试图从的ImageView 没有滚动的时候发生。

Notice that i've added added android:fillViewport="true" to NestedScrollView and also added app:layout_scrollFlags="scroll" to the ImageView but when trying to scroll from the ImageView nothing happens.

推荐答案

OK,我做了一些研究,在错误报告,和这是设计支持库中的一个已知的bug

OK, I did some research in the bug reports, and this is a known bug within the Design Support Library.

<一个href="https://$c$c.google.com/p/android/issues/detail?id=176673&q=collapsingToolbarLayout%20scroll&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars"相对=nofollow>此处退房的bug报告

我已经采取了看看那个备份 CoordinatorLayout / AppBarLayout /的的实施行为类等。 AppBarLayout 默认使用的 AppBarLayout.Behavior 定义的行为。这延伸 ViewOffsetBehavior 从而延长行为。该基地行为类有方法 onInterceptTouchEvent()的onTouchEvent(),这两者返回false(意思是我们不想处理触摸事件)。这些方法不受任何覆盖 ViewOffsetBehavior AppBarLayout.Behavior ,这意味着触摸是左未处理 - 这就是为什么它什么都不做。

I have taken a look at the implementation that backs CoordinatorLayout/AppBarLayout/the Behavior classes etc. The AppBarLayout uses the behaviour defined in AppBarLayout.Behavior by default. This extends ViewOffsetBehavior which in turn extends Behavior. The base Behavior class has the methods onInterceptTouchEvent() and onTouchEvent(), both of which return false (meaning "we don't want to handle touch events"). These methods are not overridden by either ViewOffsetBehavior or AppBarLayout.Behavior, meaning that the touch is left unhandled - which is why it does nothing.

一个可能的解决方法为第三方开发者将延长 AppBarLayout.Behavior 和实施 onInterceptTouchEvent()的onTouchEvent()并相应地操纵应用栏。

A possible workaround for third-party developers would be to extend AppBarLayout.Behavior and implement onInterceptTouchEvent() and onTouchEvent() and manipulate the app bar accordingly.

这些显示当前和预期的行为。这也可以从错误报告。

Videos

These show the current and intended behavior. These are also from the bug report.

  • https://youtu.be/xWadOVEaTSY
  • https://youtu.be/J8ITp6RusZo

这篇关于CollapsingToolbarLayout ImageView的不可滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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