我得到这样的问题:我有一个MapView和它下面的ListView。地图大小是固定的。但我需要一起滚动我的观点。我以某种方式处理了非滚动地图和单迭代列表的问题,但另一个出现了 - 在ScrollView中ListView下面有很多可用空间,我无法摆脱它。我认为将列表设置为“wrap_content”会有所帮助,但事实并非如此。 怎么办? 这里是我的布局:滚动视图不包裹其内容
<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="wrap_content" >
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<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="wrap_content"
android:orientation="vertical" >
<com.package.MyMapView
android:layout_width="match_parent"
android:layout_height="100dp"
android:clickable="true"
android:apiKey="key"
android:id="@+id/map"
android:layout_gravity="top"/>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/channelsList" >
</ListView>
</LinearLayout>
</ScrollView>
</LinearLayout>
我知道。这样的答案有很多问题,但我不问它是否是一个好主意,我只是有一个我必须达成的目标。目标是:我需要一个带有地图和列表的“页面”,它们应该可以一起滚动。 – Graykos 2012-07-17 09:15:55
所以如果你滚动地图,列表也滚动? – waqaslam 2012-07-17 09:26:51
nope。在滚动视图中有两个视图。我需要滚动地图来查看它。但是当我向下滚动列表时,我需要地图以列表滚动的方式离开屏幕。 – Graykos 2012-07-17 09:37:06