【发布时间】:2017-08-04 14:44:21
【问题描述】:
我对 Nexus 5x (7.1.2) 和 Google Pixel (7.1.1) 上的 NestedScrollView fling 有一个奇怪的问题。在其他操作系统版本上它工作正常。
弹跳动画有时会在抬起手指后立即停止。它卡住了,接下来的几次投掷也可能停止。 为了重现它,你需要上下甩动几次。
在日志中,这些弹跳在速度、方向等方面看起来几乎相同,所以我找不到这个错误的真正原因。
另外,NestedScrollView 不一定要在CoordinatorLayout 之内,也可以根本没有NestedScrollingChild。
例如,此错误可通过以下NestedScrollView 子项之一重现:
1) LinearLayout 填充有TextViews
2)WebView
3) LinearLayout 填充有RecyclerViews。
我知道RecyclerView 和CoordinatorLayout 内部的行为可能存在的问题,但这并不相关。
所以请不要提及任何
recyclerView.getLayoutManager().setAutoMeasureEnabled(true);
recyclerView.setNestedScrollingEnabled(false);
或类似的东西。
代码示例:
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Put a super long text here"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Put a super long text here"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
【问题讨论】:
-
您是否尝试过添加不同的滚动行为?
-
似乎支持库code.google.com/p/android/issues/detail?id=183738 中有一个错误链接来自此响应,他们说您可以“模拟”行为stackoverflow.com/questions/31795483/…
-
我也可以确认这个问题。它的复制非常简单。只需创建一个包含任何内容的nestedscrollview。查看与普通滚动视图的行为差异。当您快速上下滑动时,它通常会立即停止滚动。我将创建一个存储库,您可以在其中快速比较这两种情况。
-
我创建了一个仓库,您可以在其中快速测试嵌套滚动视图和普通滚动视图的不同行为。 github.com/holoduke/nestedscrollviewtest
标签: android scroll android-support-library android-7.0-nougat nestedscrollview