The scrollbar of the child HorizontalScrollView has been separated from the scrollbar of the parent ScrollView

35 views Asked by At

I'm studying android ScrollView. But, I have a problem.

The scrollbar of the child HorizontalScrollView has been separated from the scrollbar of the parent ScrollView. I have to combine two scrollbars of both ScrollViews. I tried searching for the solution. but it was failed or, please tell me other ways to solve this problem.

enter image description here

enter image description here

Thank you.

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.constraint.ConstraintLayout
    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"
    xmlns:fab="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.project.talktalk.tulre.HomeActivity"
    android:id="@id/container">

        <ScrollView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:nestedScrollingEnabled="true"
        android:scrollbars="vertical">

            <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="new recipe"
                android:textSize="25dp"
                android:textColor="@color/black"/>
            <HorizontalScrollView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:scrollbars="none">

                <android.support.v7.widget.RecyclerView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/recipeRecycler"
                    app:layoutManager="LinearLayoutManager"
                    android:orientation="horizontal">
                </android.support.v7.widget.RecyclerView>

            </HorizontalScrollView>

            <com.github.clans.fab.FloatingActionButton
            android:id="@+id/fabRecipe"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_restaurant_white_24px"
            fab:fab_size="mini"
            fab:fab_label="add recipe" />

    </com.github.clans.fab.FloatingActionMenu>

</android.support.constraint.ConstraintLayout>


<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    app:headerLayout="@layout/header"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:maxWidth="200dp"
    app:itemTextColor="@color/darkgray"
    app:itemIconTint="@color/darkgray"
    app:menu="@menu/drawer_menu"
    android:layout_gravity="start">
</android.support.design.widget.NavigationView>

</android.support.v4.widget.DrawerLayout>
1

There are 1 answers

1
Marcus On

In your ScrollView you have android:nestedScrollingEnabled="true". Set it to false and it will remove the scrollbars from the child views of the ScrollView and give you the behaviour you desire. If you have nested ScrollViews you should consider using NestedScrollView instead as nested ScrollViews are considered bad practice.