這是我的代碼,它只給我單個ListView
,如果我設置height
的ListView
到wrap_content
或match_parent
。但如果我根據dp
定義高度,它會向我展示ListView
。但在這種情況下它看起來不太好。如何在ScrollView中添加2個ListViews
<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
。
你不能把內部列表視圖ScrollViews,從來沒有。不好用。這是一個非常糟糕的選擇。真的,想想另一種方式。 – Aspicas
嘗試使用'NestedScrollView'而不是'ScrollView' –