Android无法将NestedScrollView的RelativeLayout中的ListView设置为高度

问题描述 投票:-1回答:2

所以我在NestedScrollView的RelativeLayout里面有ScrollView。一切都可以正常工作,甚至可以滚动(出于某种原因,您不能在ScrollView中滚动ListView),除非我不能将ListView的高度实际设置为wrap_content。由于某种原因,它总是在70dp左右。我尝试了一切。知道我该怎么做吗?谢谢!!

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView 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:id="@+id/nscw"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:fillViewport="true"
    tools:context=".ShowRecipe">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="1000dp">

        <ListView
            android:id="@+id/LV2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentStart="true"
            android:layout_below="@+id/TV1"
            android:paddingRight="7dp"
            android:paddingLeft="7dp"
            android:layout_marginTop="10dp" />

        <TextView
            android:id="@+id/TV1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/LV1"
            android:layout_marginTop="20dp"
            android:layout_centerHorizontal="true"
            android:text="FIRST LIST VIEW"
            android:textAlignment="center"
            android:gravity="center"
            android:textSize="30sp" />

        <TextView
            android:id="@+id/TV2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:text="SECOND LIST VIEW"
            android:textAlignment="center"
            android:textSize="30sp" />

        <ListView
            android:id="@+id/LV1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentStart="true"
            android:paddingRight="7dp"
            android:paddingLeft="7dp"
            android:layout_below="@+id/TV2"
            android:layout_marginTop="10dp" />


    </RelativeLayout>

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

所以我在NestedScrollView的RelativeLayout里面有ScrollView。一切都可以正常工作,甚至可以滚动(出于某种原因,您无法在ScrollView中滚动ListView),但我无法设置...

android listview android-relativelayout android-nestedscrollview
2个回答
0
投票

在您的NestedScrollView中将此属性设置为false


0
投票

尝试一下;

© www.soinside.com 2019 - 2024. All rights reserved.