【发布时间】:2016-10-03 12:03:14
【问题描述】:
这是我的代码,它只给我一个ListView,如果我将ListView 的height 设置为wrap_content 或match_parent。但是,如果我根据dp 定义高度,它就会开始向我显示ListView。但在那种情况下看起来并不好。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="40dp"
android:text="ListView1"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:layout_marginTop="45dp"
android:textColor="@color/white"
android:textStyle="bold" />
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lv_upcoming"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:divider="@null" />
<View
android:layout_width="fill_parent"
android:layout_height="0.5dp"
android:background="#ffffff" />
<TextView
android:layout_width="match_parent"
android:layout_height="40dp"
android:text="List Number 2"
android:gravity="center_vertical"
android:textColor="@color/white"
android:fontFamily="sans-serif-condensed"
android:textSize="18sp"
android:id="@+id/tvPrevious"
android:paddingLeft="16dp"
android:paddingRight="16dp" />
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/list_view_2"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:divider="@null"/>
</LinearLayout>
</ScrollView>
请指导我如何在布局中添加多个ListView。
【问题讨论】:
-
绝对不能将 Listviews 放入 ScrollViews 中。效果不好。这是一个非常糟糕的选择。真的,换个方式想想吧。
-
尝试使用
NestedScrollView而不是ScrollView
标签: android android-layout listview android-fragments