Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] android – linearlayout is not getting displayed below recyclerview

Posted on November 14, 2022

Solution 1 :

following solution worked for me:-

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns_android="http://schemas.android.com/apk/res/android"
xmlns_tools="http://schemas.android.com/tools"
android_layout_width="match_parent"
android_layout_height="match_parent"
xmlns_app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
    android_layout_width="match_parent"
    android_layout_height="wrap_content"
    android_id="@+id/relative">
    <androidx.appcompat.widget.Toolbar
        android_layout_width="match_parent"
        android_layout_height="wrap_content"
        app_collapseIcon="@drawable/ic_arrow_back_black_24dp"

        android_id="@+id/toolbartable"
        android_background="@color/colorPrimaryDark">

    </androidx.appcompat.widget.Toolbar>

</RelativeLayout>

 <androidx.core.widget.NestedScrollView
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_id="@+id/nest"
android_scrollbars="vertical"
android_layout_below="@id/relative">
<RelativeLayout
    android_layout_width="match_parent"
    android_layout_height="wrap_content"
    android_orientation="vertical">
  <androidx.recyclerview.widget.RecyclerView
    android_layout_width="match_parent"
    android_layout_height="wrap_content"
      android_nestedScrollingEnabled="false"
      android_id="@+id/recyleview"/>
<LinearLayout
    android_layout_width="match_parent"
    android_layout_height="100dp"
    android_id="@+id/linearlayoutorder"
     android_layout_below="@id/recyleview"
    android_orientation="horizontal"
    android_weightSum="2"
    android_background="@drawable/border"
    android_backgroundTintMode="@color/colorPrimary">
    <TextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_text="TOTAL"
        android_layout_gravity="center"
        android_layout_weight="1"></TextView>
    <TextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_layout_weight="1"
        android_id="@+id/totalidcost"
        android_layout_gravity="right|center"
        android_textAlignment="textEnd"
        tools_ignore="RtlCompat"></TextView>
</LinearLayout>
</RelativeLayout>
</androidx.core.widget.NestedScrollView>
 </RelativeLayout>

Solution 2 :

You haven’t added weightSum and orientation values ​​for LinearLayout.

Source

Solution 3 :

You can use a NestedScrollView instead of the ScrollView. And also put your RecyclerView as well as the LinearLayout inside the NestedScrollView. And enable android:nestedScrollingEnabled=true. Should work for you.

<NestedScrollView 
    android_layout_width="match_parent"
    android_layout_height="match_parent"
    android_nestedScrollingEnabled=true>
      <LinearLayout 
        android_layout_width="match_parent"
        android_layout_height="match_parent"
        android_orientation="vertical">

<androidx.recyclerview.widget.RecyclerView
        android_id="@+id/recyleview"
        android_layout_width="match_parent"
        android_layout_height="0dp"
        app_layout_constraintBottom_toTopOf="@id/linearlayoutorder"
        app_layout_constraintTop_toBottomOf="@id/relative" />

    <LinearLayout
        android_id="@+id/linearlayoutorder"
        android_layout_width="match_parent"
        android_layout_height="100dp"
        android_background="#000000"
        android_backgroundTintMode="@color/colorPrimary"
        android_orientation="horizontal"
        android_weightSum="2"
        app_layout_constraintBottom_toBottomOf="parent"
        app_layout_constraintLeft_toLeftOf="parent"
        app_layout_constraintRight_toRightOf="parent">

        <TextView
            android_layout_width="wrap_content"
            android_layout_height="wrap_content"
            android_layout_gravity="center"
            android_layout_weight="1"
            android_text="TOTAL" />

        <TextView
            android_id="@+id/totalidcost"
            android_layout_width="wrap_content"
            android_layout_height="wrap_content"
            android_layout_gravity="right|center"
            android_layout_weight="1"
            android_textAlignment="textEnd"
            tools_ignore="RtlCompat" />
    </LinearLayout>
</LinearLayout>

And in your java class where you have your recyclerview set recyclerView.setNestedScrollingEnabled(true or false);

Solution 4 :

Use ConstraintLayout like this way, Here is full xml code what you need

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns_android="http://schemas.android.com/apk/res/android"
    xmlns_app="http://schemas.android.com/apk/res-auto"
    xmlns_tools="http://schemas.android.com/tools"
    android_layout_width="match_parent"
    android_layout_height="match_parent">

    <RelativeLayout
        android_id="@+id/relative"
        android_layout_width="match_parent"
        android_layout_height="wrap_content"
        app_layout_constraintLeft_toLeftOf="parent"
        app_layout_constraintRight_toRightOf="parent"
        app_layout_constraintTop_toTopOf="parent">

        <androidx.appcompat.widget.Toolbar
            android_id="@+id/toolbartable"
            android_layout_width="match_parent"
            android_layout_height="wrap_content"
            android_background="@color/colorPrimaryDark"
            app_collapseIcon="@drawable/back" />

    </RelativeLayout>

    <androidx.recyclerview.widget.RecyclerView
        android_id="@+id/recyleview"
        android_layout_width="match_parent"
        android_layout_height="0dp"
        app_layout_constraintBottom_toTopOf="@id/linearlayoutorder"
        app_layout_constraintTop_toBottomOf="@id/relative" />

    <LinearLayout
        android_id="@+id/linearlayoutorder"
        android_layout_width="match_parent"
        android_layout_height="100dp"
        android_background="#000000"
        android_backgroundTintMode="@color/colorPrimary"
        android_orientation="horizontal"
        android_weightSum="2"
        app_layout_constraintBottom_toBottomOf="parent"
        app_layout_constraintLeft_toLeftOf="parent"
        app_layout_constraintRight_toRightOf="parent">

        <TextView
            android_layout_width="wrap_content"
            android_layout_height="wrap_content"
            android_layout_gravity="center"
            android_layout_weight="1"
            android_text="TOTAL" />

        <TextView
            android_id="@+id/totalidcost"
            android_layout_width="wrap_content"
            android_layout_height="wrap_content"
            android_layout_gravity="right|center"
            android_layout_weight="1"
            android_textAlignment="textEnd"
            tools_ignore="RtlCompat" />
    </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

Problem :

in my layout i have recyclerview of product listing..below that im displaying total price in linearlayout …but on scroll linearlayout is not displaying

sceneorio of my code:

1–> when i have one item on recyclerview –>linearlayout displays fine

READ  [ANSWERED] android - How to break the date i.e., 4/7/1995 into this: 4 + 7+ 1+9+9+5 and find the total sum in java?
Powered by Inline Related Posts

2–> when i have more items on recyclerview –>on scrolling down linearlayout cant be seen(linear layout is not displaying)

need help in second sceneorio…thanks in advance

Following here is code xml:–

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns_android="http://schemas.android.com/apk/res/android"
xmlns_tools="http://schemas.android.com/tools"
android_layout_width="match_parent"
android_layout_height="match_parent"
xmlns_app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
    android_layout_width="match_parent"
    android_layout_height="wrap_content"
    android_id="@+id/relative">
    <androidx.appcompat.widget.Toolbar
        android_layout_width="match_parent"
        android_layout_height="wrap_content"
        app_collapseIcon="@drawable/ic_arrow_back_black_24dp"

        android_id="@+id/toolbartable"
        android_background="@color/colorPrimaryDark">

    </androidx.appcompat.widget.Toolbar>

</RelativeLayout>

<ScrollView
    android_layout_width="match_parent"
    android_layout_height="wrap_content"
    android_layout_below="@id/relative"
    android_id="@+id/nest"
    android_scrollbars="vertical">
  <androidx.recyclerview.widget.RecyclerView
    android_layout_width="match_parent"
    android_layout_below="@id/relative"
    android_layout_height="wrap_content"
    android_id="@+id/recyleview"/>
</ScrollView>
<LinearLayout
    android_layout_width="match_parent"
    android_layout_height="100dp"
    android_id="@+id/linearlayoutorder"
    android_layout_below="@id/nest"
    android_orientation="horizontal"
    android_weightSum="2"
    android_background="@drawable/border"
    android_backgroundTintMode="@color/colorPrimary">
    <TextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_text="TOTAL"
        android_layout_gravity="center"
        android_layout_weight="1"></TextView>
    <TextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_layout_weight="1"
        android_id="@+id/totalidcost"
        android_layout_gravity="right|center"
        android_textAlignment="textEnd"
        tools_ignore="RtlCompat"></TextView>
</LinearLayout>
</RelativeLayout>

Updated code:–

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns_android="http://schemas.android.com/apk/res/android"
xmlns_tools="http://schemas.android.com/tools"
android_layout_width="match_parent"
android_layout_height="match_parent"
xmlns_app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
    android_layout_width="match_parent"
    android_layout_height="wrap_content"
    android_id="@+id/relative">
    <androidx.appcompat.widget.Toolbar
        android_layout_width="match_parent"
        android_layout_height="wrap_content"
        app_collapseIcon="@drawable/ic_arrow_back_black_24dp"

        android_id="@+id/toolbartable"
        android_background="@color/colorPrimaryDark">

    </androidx.appcompat.widget.Toolbar>

</RelativeLayout>
<androidx.core.widget.NestedScrollView
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_id="@+id/nest"
android_scrollbars="vertical"
android_layout_below="@id/relative">
  <androidx.recyclerview.widget.RecyclerView
    android_layout_width="match_parent"
    android_layout_height="wrap_content"
      android_nestedScrollingEnabled="false"
      android_id="@+id/recyleview"/>
<LinearLayout
    android_layout_width="match_parent"
    android_layout_height="100dp"
    android_id="@+id/linearlayoutorder"

    android_orientation="horizontal"
    android_weightSum="2"
    android_background="@drawable/border"
    android_backgroundTintMode="@color/colorPrimary">
    <TextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_text="TOTAL"
        android_layout_gravity="center"
        android_layout_weight="1"></TextView>
    <TextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_layout_weight="1"
        android_id="@+id/totalidcost"
        android_layout_gravity="right|center"
        android_textAlignment="textEnd"
        tools_ignore="RtlCompat"></TextView>
</LinearLayout>
 </androidx.core.widget.NestedScrollView>
 </RelativeLayout>

error getting–:Caused by: android.view.InflateException: Binary XML file line #34: ScrollView can host only one direct child

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

need help

Comments

Comment posted by Seddik Fredj

but if you remove item, it still take the space?

Comment posted by IRON MAN

no i did changes..doesnt worked though… situation is still the same

Comment posted by Arda Kazancı

You don’t have to use Recyclerview in scroll view.

Comment posted by IRON MAN

okay after removing scrollview ..situation is still same …not displaying after scrolling recyclerview

Comment posted by IRON MAN

i did nestedscrolling false inside recyclerview i got error ==> Caused by: android.view.InflateException: Binary XML file line #34: ScrollView can host only one direct child Caused by: java.lang.IllegalStateException: ScrollView can host only one direct child

READ  [ANSWERED] android - Not call twice: result of call Single.just() from ViewModel to Activity
Powered by Inline Related Posts

Comment posted by KalanaChinthaka

Just create a linearLayout or a RelativeLayout as a parent of your view inside the nestedScrollView. Then you should be fine. I will update my answer with the hierarchy.

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress