【发布时间】:2016-06-13 21:31:09
【问题描述】:
在 android 中,我想展示一个带有固定文本和动态列表的 UI。我添加了一个滚动视图,但它只滚动列表视图(id 是 listview_name),而不是整个视图。我该如何解决这个问题?
这是我的代码
<LinearLayout 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">
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:padding="10dp"
android:orientation="vertical"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="colorBlack"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ListView
android:id="@+id/listview_name"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="colorBlack"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
</LinearLayout>
【问题讨论】:
-
ScrollView 中不能有 ListView。这是Android本身的规则。我建议你拿列表 ScrollView。
标签: android listview scrollview