我已将滚动视图应用于整个布局,并且该布局有一个列表视图。当在模拟器中运行应用程序时,两个滚动视图都为整个布局工作一个滚动视图,为listview工作另一个滚动视图(两者都工作正常)。但是,当我在手机中安装我的应用程序时,外部滚动视图正在工作滚动视图列表视图无效。任何人都可以告诉我问题的原因和解决方案。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg4"
android:orientation="vertical"
android:scrollbarAlwaysDrawVerticalTrack="true" >
<ListView
android:id="@+id/listViewTickets"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp" >
</ListView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginBottom="70dp"
android:orientation="horizontal"
>
<Button
android:id="@+id/btnNew"
android:layout_width="80dp"
android:layout_height="30dp"
android:background="@drawable/btnnew" />
<Button
android:id="@+id/btnUpdate"
android:layout_width="80dp"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/edit" />
</LinearLayout>
列表视图的内容是动态显示的。
答案 0 :(得分:0)
列表视图已经可滚动,因此您无法将其添加到滚动视图中。 这是一个类似的问题和负责ListView的Google工程师的回答: How can I put a ListView into a ScrollView without it collapsing?
答案 1 :(得分:0)
我发现youtube视频Google I/O 2010 - The world of ListView是必不可少的手表。在其中提到永远不要使用多个滚动小部件,除非它们在不同的轴上滚动。