[英]Android cant set height to ListView in RelativeLayout inNestedScrollView
So I have ScrollView inside RelativeLayout inside NestedScrollView.所以我在 NestedScrollView 里面的 RelativeLayout 里面有 ScrollView。 Everything works fine, even scroll (for some reason you souldnt be able to scroll ListView inside ScrollView), except I cant set ListView height to actually wrap_content.
一切正常,甚至滚动(出于某种原因,您无法在 ScrollView 中滚动 ListView),除了我无法将 ListView 高度设置为实际 wrap_content。 For some reason is always around 70dp.
出于某种原因,总是在 70dp 左右。 I tried everything on everything.
我尝试了一切。 Any idea how could I do that?
知道我怎么能这样做吗? Thanks!!!
谢谢!!!
<?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>
Try this;尝试这个;
<ScrollView 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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1000dp"
android:orientation="vertical">
<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" />
</LinearLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.