Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 滚动视图不环绕其内容_Android_Listview_Scrollview - Fatal编程技术网

Android 滚动视图不环绕其内容

Android 滚动视图不环绕其内容,android,listview,scrollview,Android,Listview,Scrollview,我遇到了这样的问题:我有一个MapView和它下面的一个ListView。地图大小是固定的。但我需要将我的视图一起滚动。一、 不知何故,我处理了非滚动地图和一个项目列表的问题,但另一个出现了——在滚动视图中,ListView下面有很多可用空间,我无法摆脱它。我认为设置列表为“wrap_ucontent”会有帮助,但它没有。 怎么办? 以下是我的布局: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/androi

我遇到了这样的问题:我有一个MapView和它下面的一个ListView。地图大小是固定的。但我需要将我的视图一起滚动。一、 不知何故,我处理了非滚动地图和一个项目列表的问题,但另一个出现了——在滚动视图中,ListView下面有很多可用空间,我无法摆脱它。我认为设置列表为“wrap_ucontent”会有帮助,但它没有。 怎么办? 以下是我的布局:

<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>

您能试着替换这些行吗:

<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" >
<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="fill_parent" >

以下几行:

<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" >
<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="fill_parent" >

您能试着替换这些行吗:

<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" >
<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="fill_parent" >

以下几行:

<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" >
<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="fill_parent" >


列表视图包装在滚动视图内部始终不是一个好主意,因为两者都是可滚动视图。

列表视图包装在滚动视图内部始终不是一个好主意,因为两者都是可滚动视图。

不要在滚动视图中插入任何列表视图,在任何情况下都不能满足您的要求。尝试将地图视图添加为ListView的标题,使其与列表一起滚动


要将mapView实现为标头,在java代码中,只需将
addHeaderView()
包含到listView组件中即可。必须在调用
setAdapter()
之前调用此函数

不要在滚动视图中插入任何在任何情况下都不能满足您要求的列表视图。尝试将地图视图添加为ListView的标题,使其与列表一起滚动


要将mapView实现为标头,在java代码中,只需将
addHeaderView()
包含到listView组件中即可。必须在调用
setAdapter()
之前调用此函数

我知道。有很多问题都有这样的答案,但我不会问这是不是一个好主意,我只是有一个我必须实现的目标。目标是:我需要一个带有地图和列表的“页面”,应该可以一起滚动。所以如果你滚动地图,列表也会滚动?不。滚动视图中有两个视图。我需要滚动地图来浏览一下。但是当我向下滚动列表时,我需要地图以列表滚动的形式离开屏幕。然后尝试添加地图作为我知道的ListView的标题视图。有很多问题都有这样的答案,但我不会问这是不是一个好主意,我只是有一个我必须实现的目标。目标是:我需要一个带有地图和列表的“页面”,应该可以一起滚动。所以如果你滚动地图,列表也会滚动?不。滚动视图中有两个视图。我需要滚动地图来浏览一下。但是当我向下滚动列表时,我需要地图以列表滚动的形式离开屏幕。然后尝试将地图添加为ListView的标题视图。我尝试了,但无法将地图添加为标题。现在我得到了一张地图和一张列表,问题是:在我的列表下面有很多空白。我试过了,但是我不能添加一个地图作为标题。现在我得到了一张地图和一张列表,问题是:在我的列表下面有很多空白。这(我想)是不应该的。填充的父对象被匹配的父对象替换了。这表示相同,但应使用后一个。填充父项已替换为匹配父项。它的意思是相同的,但应使用后一个。