D
D
Danila Suck2021-04-10 19:06:02
Android
Danila Suck, 2021-04-10 19:06:02

How to make this effect with scroll?

6071cca9034cc616974487.png
I have a ScrollView which has height and width set to match_parent. This ScrollView has a RelativeLayout with content. When the user scrolls the screen, this RelativeLayout covers the top of the screen. But the problem is that in this upper part of the screen, in addition to different views, there is a close button that should be pressed when it is visible, but when the lower RelativeLayout covers it, it should stop being pressed. The problem is that the ScrollView does not allow this very button to be pressed. If I place the button in the ScrollView according to the XML hierarchy, then it will also scroll, but I need the top views and this button to remain 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>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2021-04-10
@zagayevskiy

Add a transparent view at the top of the scroll. Make her and all the ancestor unclickable. Let the close button be below it. In theory, it should work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question