Not only Horizontal, but also any vertical scrollview will also give this error. An error means that there should be only one child in a scrollview, and this child can contain any number of children.
So, the bottom line is that you have to make only one direct child element for scrolling and make your layout in this child only as
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tool" android:id="@+id/horizontalScrollView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:fillViewport="true" > <LinearLayout android:id="@+id/directchild" android:layout_width="wrap_content" android:layout_height="fill_parent" android:orientation="horizontal" android:background="#ff0000"> </LinearLayout> </HorizontalScrollView>
Now create the desired layout in the directchild layout. You will not get any error and then
source share