0

ScrollView is not scrolling when having multiple linearLayouts in it. ScrollView is also inside a linearLayout. Below is my fragment.xml code

I am using youtubePlayer above the screen and under this using buttons to play other videos in scroll view.

I have searched and change accordingly but not solved.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<FrameLayout
    android:id="@+id/youtube_frame"
    android:layout_width="0dp"
    android:layout_height="230dp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

        <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toBottomOf="@+id/linearTitle"
        android:orientation="vertical"
        >

        <ScrollView

            android:id="@+id/scrollView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_constraintTop_toBottomOf="@+id/linearTitle"
            android:layout_marginTop="10dp"
            android:isScrollContainer="false"
            android:fitsSystemWindows="true"
            android:fillViewport="true"
            >


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="vertical">


                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:orientation="horizontal"
                    android:weightSum="4.0">


                          <My ImageButtons>


                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:orientation="horizontal"
                    android:weightSum="4.0">


                   <My ImageButtons>

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:orientation="horizontal"
                    android:weightSum="4.0">


                    <My ImageButtons>

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:orientation="horizontal"
                    android:weightSum="4.0">

                  <My ImageButtons>

                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:orientation="horizontal"
                    android:weightSum="4.0">


                   <My ImageButtons>

                </LinearLayout>



                <View
                    android:layout_width="match_parent"
                    android:layout_height="50dp" />

            </LinearLayout>



        </ScrollView>

        </LinearLayout>


</androidx.constraintlayout.widget.ConstraintLayout>
Apurv
  • 391
  • 2
  • 9
Ghazali
  • 1
  • 3
  • Scroll view only supports one direct child. See this question https://stackoverflow.com/questions/4259607/if-scrollview-only-supports-one-direct-child-how-am-i-supposed-to-make-a-whole – blaffie Jun 25 '19 at 11:57

1 Answers1

0

First of all, there is no need to put ScrollView inside LinearLayout (since this LinearLayout doesn't have any element other than ScrollView). Second, you should put your ScrollView to the bottom of your FrameLayout.

Refer below :

    <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <FrameLayout
        android:id="@+id/youtube_frame"
        android:layout_width="0dp"
        android:layout_height="230dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />


    <ScrollView

        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:fillViewport="true"
        android:fitsSystemWindows="true"
        android:isScrollContainer="false"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/youtube_frame">


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="vertical">


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="horizontal"
                android:weightSum="4.0">


                <My ImageButtons>


            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="horizontal"
                android:weightSum="4.0">


                <My ImageButtons>

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="horizontal"
                android:weightSum="4.0">


                <My ImageButtons>

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="horizontal"
                android:weightSum="4.0">

                <My ImageButtons>

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="horizontal"
                android:weightSum="4.0">


                <My ImageButtons>

            </LinearLayout>


            <View
                android:layout_width="match_parent"
                android:layout_height="50dp" />

        </LinearLayout>


    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>
Apurv
  • 391
  • 2
  • 9