簡體   English   中英

如何使用 ScrollView 制作這種效果?

[英]How to make this effect with ScrollView?

我有一個ScrollView ,它的高度和寬度設置為match_parent 這個ScrollView有一個帶內容的RelativeLayout 當用戶滾動屏幕時,此RelativeLayout覆蓋屏幕頂部。 但問題是,在屏幕的這個上部,除了不同的視圖,還有一個close按鈕,當它可見時應該是可以點擊的,當下面的RelativeLayout覆蓋它時,它應該是不可點擊的。 問題是ScrollView不允許單擊此按鈕。 如果我們沿 XML 層次結構排列ScrollView中的按鈕,那么它也會滾動,但我需要頂視圖和此按鈕保持 static。 這是應該如何的圖像

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

我將CollapsingToolbarLayoutNestedScrollView一起使用

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM