我的 overScroll 在 CoordinatorLayout 外层
时间: 2023-08-06 22:14:45 浏览: 50
如果您希望在 CoordinatorLayout 的外部添加 overScroll 效果,可以使用 NestedScrollView。NestedScrollView 是一个可以嵌套在 CoordinatorLayout 中的滚动视图,它提供了 overScroll 的效果。
以下是一个示例布局:
```xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Your other views here -->
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="always">
<!-- Your content goes here -->
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
```
这样可以在您的布局中添加 overScroll 效果,而不影响 CoordinatorLayout 中的其他滚动效果。注意,`android:overScrollMode="always"` 属性用于启用 overScroll 效果。