【发布时间】:2015-11-21 07:05:34
【问题描述】:
我试图在一个线性布局内滚动列表视图,但它没有按我的意愿工作。我附上一张图片以获得更多解释。 这是我的布局
<android.support.v7.widget.CardView
android:id="@+id/card"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:clickable="false"
app:cardBackgroundColor="@android:color/white"
app:cardElevation="2dp"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ListView
android:id="@+id/listView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:gravity="center|bottom"
android:orientation="vertical">
<Button
android:id="@+id/findSelected"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center"
android:background="@drawable/flat_selector_green"
android:text="Next"
android:textColor="@android:color/white" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</android.support.v7.widget.CardView>
我知道这不是使用列表视图的好方法,但我必须这样做。
【问题讨论】:
-
你的意思是你想要 list1 和项目 1,2 list2 和项目 3,4,5,6,7 =>list 1,2,3,4,5,6,7?跨度>
-
@tinysunlight 是的,我希望所有值首先滚动,然后第二个列表元素滚动
-
为什么需要
ScrollView?ListViews 自己滚动。 -
您可以将所有数据放在一个列表中。为什么不将它们放在一起?
-
@MikeM。当我删除滚动视图时,我的第二个列表是滚动的,但不是第一个
标签: android android-layout android-listview android-xml android-scrollview