Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8970545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:44:27+00:00 2026-06-15T17:44:27+00:00

I get the Exception: java.lang.IllegalStateException: ScrollView can host only one direct child This is

  • 0

I get the Exception:

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

This is my layout:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/frame"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/bg_listgrey"
    android:scrollbars="none" >

    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@color/bg_listgrey" >

        <RelativeLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/rl1">

            <ImageView
               />

            <TextView
                />

            <TextView
               />

            <TextView
                />
        </RelativeLayout>

        <RelativeLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/rl2"" >

            <ImageView
                 />

            <TextView
                 />
        </RelativeLayout>
    </RelativeLayout>

</ScrollView>

The same layout worked fine in case of an Activity. Where as it gives the exception when using in a Fragment.

MainActivity:

FragmentTransaction t = this.getSupportFragmentManager()
        .beginTransaction();
t.add(R.id.frame, new mFragment());
t.commit();

Thank you

EDIT:

Bit if i wrap this ScrollView in a FragmeLayout, it works fine.

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/frame"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/bg_listgrey" >

    <ScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scrollbars="none" >
.......
.......
.......
</ScrollView>
</FramLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:44:28+00:00Added an answer on June 15, 2026 at 5:44 pm

    The same layout worked fine in case of an Activity. Where as it gives
    the exception when using in a Fragment.

    The layout will work just fine as the content view for an Activity(but try to add another view to the ScrollView and see how it goes;) ) and it will work as well for a Fragment, you just don’t use it well. This:

    t.add(R.id.frame, new mFragment());
    

    will add the Fragment's view(the one created in onCreate) to the ScrollView(the ScrollView has the id R.id.frame), meaning that you’ll have two views in the ScrollView(which is not allowed): the RelativeLayout and the root of the Fragment‘s view. The addView methods of the ScrollView class will check to enforce that you end up with a single child in the ScrollView.

    Bit if i wrap this ScrollView in a FragmeLayout, it works fine.

    This is normal as you add the Fragment‘s view to the parent FrameLayout and not to the ScrollView.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sometimes I get an error (exception): java.lang.IllegalStateException: Dispatch not hooked to windows memory What
I am getting the following exception: java.lang.IllegalStateException: get field slot from row 0 col
I get the following exception java.lang.NumberFormatException: Invalid int: It is happening when you try
I get a java.lang.outOfMemoryError exception, while writing a big file to the servletOutputStream. Every
A quick question regarding the java.lang.VerifyError exception. Suppose I get an error that looks
I'm using websphere and Java EE and get this error message: Exception reading propertiesfile
With my eclipse plugin launching, I got Root exception:java.lang.IllegalStateException: Workbench has not been created
I'm catching all exceptions within: java.lang.Throwable /page.xhtml java.lang.Error /page.xhtml But what If I get
I get the following Exception running my app: java.net.SocketException: Permission denied (maybe missing INTERNET
I get the following error when I run a java program: Exception in thread

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.