【发布时间】:2020-01-08 17:48:02
【问题描述】:
所以我在 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>
【问题讨论】:
-
避免在
ListView、stackoverflow.com/questions/11295080中使用wrap_content
标签: android listview android-relativelayout android-nestedscrollview