0

Can anyone help me to solve this?

java.lang.IllegalStateException: ScrollView can host only one direct child

I get this error because I have used ScrollView in both fragments. How to solve this?

I have to use ScrollView in both fragments, but I can't. Is there any way? I can't move from one fragment to another. If I tried to do so then the following exception is thrown:

java.lang.IllegalStateException: ScrollView can host only one direct child

1
  • Please provide enough code so others can better understand or reproduce the problem. Commented Feb 20, 2023 at 19:41

1 Answer 1

0

It's hard to know what the problem really is without being able to read your code, but I bet you have a tag with multiple tags inside it.

If for example you have something like this:

<ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

           <LinearLayout
                        ...
           </LinearLayout>

           <LinearLayout
                        ...
           </LinearLayout>
</ScrollView>

Try switching to this:

<ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

           <LinearLayout
                        ...
           </LinearLayout>
</ScrollView>

ScrollView tags only allow one direct child for each. Avoid using nested ScrollViews too

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.