为什么我的嵌套滚动视图仅显示一个元素?我尝试了 fillViewport ,this solution ...我已经看到,对于某人而言,fillViewPort足够了,但显然对我来说还不够...
更新:请参阅我的完整代码。如果可以解决我的问题,我将尝试添加一个recyclerView,适配器和其他相关内容。
<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>
答案 0 :(得分:0)
您应该不嵌套多个可滚动布局(嵌套Scrollview + ListView)。 ListView容器应为不可滚动的ViewGroup,例如LinearLayout。为您的ListView提供父级不可滚动布局
<?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>