'Expandable view along with scroll view in android studio not working

I have a scroll view which I would like to extend when a certain button is clicked. I wrote the following code for the scroll view and the button click event.

The view is getting displayed but I am not able to scroll it.

Scroll view

<ScrollView
            android:id="@+id/basics_expandable_view"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:visibility="gone">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">
                <TextView
                    android:id="@+id/basics_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/todo"
                    android:layout_gravity="center"
                    android:layout_marginTop="50dp"
                    android:textSize="30sp"
                    />

                <Button
                    android:id="@+id/basics_km"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginTop="600dp"
                    android:text="@string/know_more"
                    />
            </LinearLayout>
        </ScrollView>

For the button click event

ScrollView basics_expandable_view;
    basics_expandable_view = findViewById(R.id.basics_expandable_view);
    basics_ea = findViewById(R.id.basics_button);
    basics_ea.setOnClickListener(view -> {
        if(basics_expandable_view.getVisibility() == View.GONE){
            TransitionManager.beginDelayedTransition(basics , new AutoTransition());
            basics_expandable_view.setVisibility(View.VISIBLE);

        } else {
            TransitionManager.beginDelayedTransition(basics , new AutoTransition());
            basics_expandable_view.setVisibility(View.GONE);

        }
    });


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source