Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

ScrollView can host only one direct child

Hi,
I am trying to add HorizontalScrollView in ScrollView like below
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:padding="10dp" android:fillViewport="false"> <include layout="@layout/app_bar" /> <HorizontalScrollView android:layout_width="wrap_content" android:layout_height="wrap_content" android:scrollbars="none"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> </LinearLayout> </HorizontalScrollView> </ScrollView> </LinearLayout>

It shows "ScrollView can host only one direct child" exception.Please help me how to add HorizontalScrollView to ScrollView.

Thank you.

Posts

  • BerayBentesenBerayBentesen TRUniversity ✭✭✭✭

    @rajveer put everything inside scrollview into Linearlayout. ScrollView can has only one LinearLayout or RelativeLayout.

  • rajveerrajveer USMember ✭✭
    edited December 2016

    Thank you @BerayBentesen. I change like

    <ScrollView 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"> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> <include layout="@layout/app_bar" /> <HorizontalScrollView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="clip_horizontal"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <include layout="@layout/TabGrid" /> </LinearLayout> </HorizontalScrollView> </LinearLayout> </ScrollView>

Sign In or Register to comment.