java - 如何使用 ScrollView 制作这种效果?
问题描述
我有一个ScrollView
高度和宽度设置为match_parent
. 这ScrollView
有一个RelativeLayout
内容。当用户滚动屏幕时,它RelativeLayout
会覆盖屏幕的顶部。但问题是,在屏幕的这个上部,除了不同的视图外,还有一个close
按钮,当它可见时应该是可以点击的,当下面RelativeLayout
覆盖它时,它应该是不可点击的。问题是ScrollView
不允许单击此按钮。如果我们ScrollView
沿 XML 层次结构排列按钮,那么它也会滚动,但我需要顶部视图和此按钮保持静态。这是应该如何的图像。
<carbon.widget.RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cyan"
tools:context=".OptionsActivity">
<carbon.widget.Button
android:id="@+id/close"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/close"
android:layout_alignParentEnd="true"
android:layout_marginTop="60dp"
android:layout_marginEnd="21dp"
app:carbon_elevation="0dp" />
<com.xw.repo.widget.BounceScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:scrollbars="none">
<carbon.widget.RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="110dp"
android:fillViewport="true">
<!-- content -->
</carbon.widget.RelativeLayout>
</com.xw.repo.widget.BounceScrollView>
</carbon.widget.RelativeLayout>
解决方案
CollapsingToolbarLayout
我用过NestedScrollView
推荐阅读
- angular - 在 HTML 输入元素上使用 Angular 进行事件绑定
- python - 从 expressJs 服务器执行 python 脚本
- javascript - Firefox 滚动问题 google Picker
- java - 春季插入数据字符串List Map类型时如何修复null
- reactjs - 将函数作为道具传递
- python - Visual Studio 在 pip 安装期间未检测到文件
- python - 基于 Pandas 数据框列中的非统一数据的函数中的返回值
- php - 在 MySQL 中包含空格的最佳排序规则是什么?
- javascript - 通过 RangeSlider 显示/隐藏 DIV 元素
- javascript - 无法集成条件编译库(Vue3、ifdef)