Projet Sin
Projet Sin

Reputation: 357

Nested Scroll View and list view show only 1 element

why is my nested scrollview is showing only one element ? I tried fillViewport, this solution... I've seen that for someone fillViewPort was enough, but not for me apparently...

UPDATE : see my full code please. I'll try to add a recyclerView, adapter and other related things if this could fix my problem.

<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingTop="0dp"
    android:paddingStart="20dp"
    android:paddingEnd="20dp">


    <LinearLayout
        android:id="@+id/layoutDepart"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:orientation="vertical">

        <LinearLayout
            android:id="@+id/layoutSearchViewDepart"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/background_input_no_padding"
            android:orientation="horizontal"
            android:weightSum="1">

            <android.support.v7.widget.SearchView
                android:id="@+id/searchDepart"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_margin="0dp"
                android:layout_weight="0.95"
                android:background="@color/colorWhite"
                android:padding="0dp"
                app:defaultQueryHint="Arrêt de départ"
                app:iconifiedByDefault="false"
                app:queryHint="Arrêt de départ"

                >

                <SearchView
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent" />
            </android.support.v7.widget.SearchView>

        </LinearLayout>

        <LinearLayout
            android:id="@+id/resSelectionLigneDepart"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/layoutSearchViewDepart"
            android:background="@color/grayBg"
            android:orientation="vertical"
            android:visibility="visible"
            >

            <ListView
                android:id="@+id/listSearchViewDepart"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:divider="@null"
                android:dividerHeight="0dp"
                android:translationZ="15dp"
                android:visibility="visible"
                />
        </LinearLayout>


    </LinearLayout>    
</LinearLayout>

Upvotes: 1

Views: 991

Answers (1)

Nicola Gallazzi
Nicola Gallazzi

Reputation: 8705

You should not nest multiple scrollable layouts (Nested Scrollview + ListView). ListView container should be a non-scrollable ViewGroup like LinearLayout. Give to your ListView a parent non-scrollable layout

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        xmlns:android="http://schemas.android.com/apk/res/android">
    <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:paddingTop="0dp"
            android:paddingStart="20dp"
            android:paddingEnd="20dp">


        <LinearLayout
                android:id="@+id/layoutDepart"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dp"
                android:orientation="vertical">

            <LinearLayout
                    android:id="@+id/layoutSearchViewDepart"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/background_input_no_padding"
                    android:orientation="horizontal"
                    android:weightSum="1">

                <android.support.v7.widget.SearchView
                        android:id="@+id/searchDepart"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_margin="0dp"
                        android:layout_weight="0.95"
                        android:background="@color/colorWhite"
                        android:padding="0dp"
                        app:defaultQueryHint="Arrêt de départ"
                        app:iconifiedByDefault="false"
                        app:queryHint="Arrêt de départ">

                    <SearchView
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent" />
                </android.support.v7.widget.SearchView>

            </LinearLayout>

            <LinearLayout
                    android:id="@+id/resSelectionLigneDepart"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/layoutSearchViewDepart"
                    android:background="@color/grayBg"
                    android:orientation="vertical"
                    android:visibility="visible"
            >

                <ListView
                        android:id="@+id/listSearchViewDepart"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:divider="@null"
                        android:dividerHeight="0dp"
                        android:translationZ="15dp"
                        android:visibility="visible"
                />
            </LinearLayout>


        </LinearLayout>
    </LinearLayout>
</android.support.v4.widget.NestedScrollView>

Upvotes: 1

Related Questions