gpt4 book ai didi

android - CollapsingToolbarLayout ImageView 不可滚动

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:57:07 24 4
gpt4 key购买 nike

使用 cheesesquare - android support library example是否可以使 Header ImageView 可滚动?

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

注意我已经添加了 android:fillViewport="true"NestedScrollView 并且还添加了 app:layout_scrollFlags="scroll"ImageView 但是当尝试从 ImageView 滚动时没有任何反应。

最佳答案

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

Check out the bug report here

摘录

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.

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

视频

这些显示了当前和预期的行为。这些也来自错误报告。

关于android - CollapsingToolbarLayout ImageView 不可滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30706500/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com