Home > Enterprise >  How to do this ScrollView can host only one direct child androidx.core.widget.NestedScrollView This
How to do this ScrollView can host only one direct child androidx.core.widget.NestedScrollView This

Time:01-13

android.view.InflateException: Binary XML file line #44: ScrollView can host only one direct childCaused by: java.lang.IllegalStateException: ScrollView can host only one direct child at android.widget.ScrollView.addView(ScrollView.java:279) atretrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:70)

<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:aapt="http://schemas.android.com/aapt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/half_view_margin_standard"
android:layout_marginTop="@dimen/view_margin_standard"
android:layout_marginRight="@dimen/half_view_margin_standard"
android:layout_marginBottom="@dimen/half_view_margin_standard">



<LinearLayout

    android:orientation="vertical"
    android:id="@ id/ll_home_header_parent"
    android:background="@color/card_background_color"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.core.widget.NestedScrollView
        android:id="@ id/scrollView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true">


    <TextView
        android:textSize="@dimen/app_titles_text_size"
        android:textStyle="bold"
        android:textColor="@color/abc_decor_view_status_guard"
        android:gravity="center"
        android:layout_gravity="center"
        android:id="@ id/tv_month_name"
        android:paddingTop="@dimen/view_margin_standard"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:text="மே - திங்கள்"/>
    <LinearLayout android:gravity="center" android:layout_gravity="center" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="@dimen/half_view_margin_standard">
        <TextView android:textSize="@dimen/app_display_type_1_text_size"
            android:textColor="@color/abc_decor_view_status_guard"
            android:gravity="center"
            android:layout_gravity="center"
            android:id="@ id/tv_date"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="08-05-2017"
            android:fontFamily="@font/product_bold"/>
    </LinearLayout>


    <LinearLayout
        android:layout_width="335dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="@dimen/half_view_margin_standard"
        android:layout_marginBottom="@dimen/half_view_margin_standard"
        android:orientation="horizontal">
        <TextView
            android:id="@ id/sf"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginLeft="@dimen/half_view_margin_standard"
            android:gravity="left"
            android:text="நல்ல நேரம்"
            android:textColor="@color/black"
            android:textSize="@dimen/app_body_type_1_text_size" />

        <TextView
            android:id="@ id/tv_morning"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginLeft="@dimen/half_view_margin_standard"
            android:gravity="left"
            android:text="கா"
            android:textColor="@color/black"
            android:textSize="@dimen/app_body_type_1_text_size" />

        <TextView
            android:id="@ id/tv_morning_time"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginLeft="@dimen/half_view_margin_standard"
            android:gravity="left"
            android:text="10.30 - 12.00"
            android:textColor="@color/black"
            android:textSize="@dimen/app_body_type_1_text_size" />

        <TextView
            android:id="@ id/tv_evening"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginLeft="@dimen/half_view_margin_standard"
            android:text="மா"
            android:textColor="@color/black"
            android:textSize="@dimen/app_body_type_1_text_size" />

        <TextView
            android:id="@ id/tv_evening_time"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_marginLeft="@dimen/half_view_margin_standard"
            android:gravity="left"
            android:text="10.30 - 12.00"
            android:textColor="@color/black"
            android:textSize="@dimen/app_body_type_1_text_size" />
    </LinearLayout><![CDATA[ 7.00 Maalai 4.30 - 6.00"/>


    ]]>



    <LinearLayout

        android:orientation="vertical"
        android:background="@color/card_background_color"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <TextView
            android:id="@ id/tv_tamil_month_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_gravity="center"
            android:layout_marginLeft="@dimen/half_view_margin_standard"
            android:gravity="center"
            android:text="சித்திரைத்"
            android:textColor="@color/abc_decor_view_status_guard"
            android:textSize="@dimen/app_big_sub_heads_text_size" />

        <TextView
            android:id="@ id/tv_viratham_home"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_gravity="center"
            android:layout_marginLeft="@dimen/half_view_margin_standard"
            android:gravity="center"
            android:text="சித்திரைத்"
            android:textColor="@color/abc_decor_view_status_guard"
            android:textSize="@dimen/app_big_sub_heads_text_size" />

        <TextView
            android:id="@ id/tv_viratham_time_range"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_gravity="center"
            android:layout_marginLeft="@dimen/half_view_margin_standard"
            android:gravity="center"
            android:text="சித்திரைத்"
            android:textColor="@color/abc_decor_view_status_guard"
            android:textSize="@dimen/app_big_sub_heads_text_size" />

        <TextView
            android:textSize="@dimen/app_body_type_1_text_size"
            android:textColor="@color/black"
            android:gravity="center"
            android:layout_gravity="center"
            android:id="@ id/tv_vishesham"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/half_view_margin_standard"
            android:text="காலை"/>
    </LinearLayout>


    </androidx.core.widget.NestedScrollView>
</LinearLayout>

</androidx.cardview.widget.CardView>`

`

how to clear error this

CodePudding user response:

you should use scrollview like this sample

<androidx.core.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    
    <androidx.appcompat.widget.LinearLayoutCompat
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        
        <TextView />

        <TextView />

        <TextView />
        
    </androidx.appcompat.widget.LinearLayoutCompat>
    
</androidx.core.widget.NestedScrollView>

Not Like this

<androidx.core.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <androidx.appcompat.widget.LinearLayoutCompat
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

    </androidx.appcompat.widget.LinearLayoutCompat>

    <TextView />

    <TextView />

    <TextView />

</androidx.core.widget.NestedScrollView>
  • Related