我在这里很近,我尝试了很多东西,但无法让它工作。我在这里有两个列表视图。我想要的是每个listview显示其整个内容。我不希望列表视图滚动。我想要保持列表视图可滚动的滚动视图。最近我已经能够得到它(这是错误的),以便每个listview是可滚动的。这意味着每个listview只显示为1 1/2个单元格。我认为这将是一件简单的事情,但Android有一些奇怪的事情发生。两个ListViews&ScrollView
因此,每个列表视图都会显示其全部内容,即使内容高度超过了屏幕。然后,我所要做的就是向下滚动查看显示其全部内容的第二个列表视图。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:orientation="vertical"
android:fillViewport="true">
<LinearLayout
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:orientation="vertical"
android:fillViewport="true">
<LinearLayout
android:layout_weight="10"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CCCCCC"
android:text="@string/alerts_top_title"
android:gravity="center"
android:textColor="#000000"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
</TextView>
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/cameraListAlerts" >
</ListView>
</LinearLayout>
<LinearLayout
android:layout_weight="10"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<TextView
android:gravity="center"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#CCCCCC"
android:textColor="#000000"
android:text="@string/alerts_bottom_title">
</TextView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="8dp">
</LinearLayout>
<Button
android:id="@+id/addRecipient"
android:layout_height="50dp"
android:layout_width="fill_parent"
android:layout_centerHorizontal="true"
android:text="@string/addRecipient"/>
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/recipientListAlerts" >
</ListView>
</LinearLayout>
</LinearLayout>
</ScrollView>
'ListView'不会进入'ScrollView's。以编程方式将您的列表填充到LinearLayout中,而不是使用ListView。这正是你想要的。 –
我知道一个人会被抛出去。没有办法,我可以在没有做这么多工作的情况下让它工作吗? – spentak