带有一些文本和地图视图的滚动视图布局出现问题...我无法移动地图

发布于 2024-10-07 17:51:13 字数 5468 浏览 0 评论 0原文

我有一个滚动视图布局,有一些文本视图和按钮,中间还有一个地图视图。这个布局的所有内容都在滚动视图上,因为它有很多东西,用户必须滚动窗口才能看到所有内容。

但后来我遇到了一个问题,当用户尝试移动地图时,它不会移动,并且由于滚动视图,手指滚动整个窗口。能够滚动整个窗口很酷,但我希望当用户在地图上移动手指时,用户只滚动地图。

有没有办法在不删除滚动视图的情况下解决这个问题?我需要它!

有代码:

<?xml version="1.0" encoding="utf-8"?>

<ScrollView android:id="@+id/ScrollView01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

<LinearLayout 
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:padding="10px">

<RelativeLayout
    android:gravity="center_vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView
        android:id="@+id/UserLabel" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5px"
        android:text="@string/userlabel"/>
    <TextView
        android:id="@+id/User"
        android:layout_alignBaseline="@id/UserLabel"
        android:layout_alignParentRight="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</RelativeLayout>

<RelativeLayout
    android:gravity="center_vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView
        android:id="@+id/PermissionLabel" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="13px"
        android:text="@string/perlabel"/>
    <TextView
        android:id="@+id/Permission"
        android:layout_alignBaseline="@+id/PermissionLabel"
        android:layout_alignParentRight="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</RelativeLayout>

<RelativeLayout
    android:gravity="center_vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView
        android:id="@+id/FromLabelLocate" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="13px"
        android:text="@string/fromlabel"/>
    <TextView
        android:id="@+id/FromLocate"
        android:layout_alignBaseline="@+id/FromLabelLocate"
        android:layout_alignParentRight="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</RelativeLayout>

<RelativeLayout
    android:gravity="center_vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView
        android:id="@+id/ToLabelLocate" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="13px"
        android:text="@string/tolabel"/>
    <TextView
        android:id="@+id/ToLocate"
        android:layout_alignBaseline="@+id/ToLabelLocate"
        android:layout_alignParentRight="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</RelativeLayout>

<RelativeLayout
    android:gravity="center_vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView
        android:id="@+id/LastUpdateLabel" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="13px"
        android:text="@string/lastupdatelabel"/>
    <TextView
        android:id="@+id/LastUpdate"
        android:layout_alignBaseline="@id/LastUpdateLabel"
        android:layout_alignParentRight="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</RelativeLayout>

<View
    android:layout_gravity="center_horizontal"
    android:layout_width="fill_parent"
    android:layout_height="1dip"
    android:background="#808080"
    android:layout_marginTop="5px"
    android:layout_marginBottom="10px"/>

<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="230px"
    android:clickable="true"
    android:apiKey="mykey"
/>

<View
    android:layout_gravity="center_horizontal"
    android:layout_width="fill_parent"
    android:layout_height="1dip"
    android:background="#808080"
    android:layout_marginTop="10px"
    android:layout_marginBottom="10px"/>

<RelativeLayout
    android:gravity="center_vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <Button
        android:id="@+id/locate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/locate"
        android:width="130px"
        android:layout_marginLeft="15dip"/>
    <Button
        android:id="@+id/trace"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/trace"
        android:width="130px"
        android:layout_alignBaseline="@id/locate"
        android:layout_alignParentRight="true"
        android:layout_marginRight="15dip"/>
</RelativeLayout>

</LinearLayout>
</ScrollView>

i have a scrollview layout, with some textviews and buttons, and also a mapview in the middle.All the content of this layout is on a scrollview, because it haves a lot of things, and user have to scroll the windows to see all.

But then i have a problem, when the user tryes to move the map, it doesn't move, and the finger scrolls the entire window, because of the scrollview. Its cool to have the possibility to scroll the entire window, but i want that when the user moves the finger on the map, the user scrolls only the map.

exist a way to fix this problem without removing the scrollview? i need it!

there is the code:

<?xml version="1.0" encoding="utf-8"?>

<ScrollView android:id="@+id/ScrollView01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

<LinearLayout 
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:padding="10px">

<RelativeLayout
    android:gravity="center_vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView
        android:id="@+id/UserLabel" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5px"
        android:text="@string/userlabel"/>
    <TextView
        android:id="@+id/User"
        android:layout_alignBaseline="@id/UserLabel"
        android:layout_alignParentRight="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</RelativeLayout>

<RelativeLayout
    android:gravity="center_vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView
        android:id="@+id/PermissionLabel" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="13px"
        android:text="@string/perlabel"/>
    <TextView
        android:id="@+id/Permission"
        android:layout_alignBaseline="@+id/PermissionLabel"
        android:layout_alignParentRight="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</RelativeLayout>

<RelativeLayout
    android:gravity="center_vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView
        android:id="@+id/FromLabelLocate" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="13px"
        android:text="@string/fromlabel"/>
    <TextView
        android:id="@+id/FromLocate"
        android:layout_alignBaseline="@+id/FromLabelLocate"
        android:layout_alignParentRight="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</RelativeLayout>

<RelativeLayout
    android:gravity="center_vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView
        android:id="@+id/ToLabelLocate" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="13px"
        android:text="@string/tolabel"/>
    <TextView
        android:id="@+id/ToLocate"
        android:layout_alignBaseline="@+id/ToLabelLocate"
        android:layout_alignParentRight="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</RelativeLayout>

<RelativeLayout
    android:gravity="center_vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView
        android:id="@+id/LastUpdateLabel" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="13px"
        android:text="@string/lastupdatelabel"/>
    <TextView
        android:id="@+id/LastUpdate"
        android:layout_alignBaseline="@id/LastUpdateLabel"
        android:layout_alignParentRight="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
</RelativeLayout>

<View
    android:layout_gravity="center_horizontal"
    android:layout_width="fill_parent"
    android:layout_height="1dip"
    android:background="#808080"
    android:layout_marginTop="5px"
    android:layout_marginBottom="10px"/>

<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="230px"
    android:clickable="true"
    android:apiKey="mykey"
/>

<View
    android:layout_gravity="center_horizontal"
    android:layout_width="fill_parent"
    android:layout_height="1dip"
    android:background="#808080"
    android:layout_marginTop="10px"
    android:layout_marginBottom="10px"/>

<RelativeLayout
    android:gravity="center_vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <Button
        android:id="@+id/locate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/locate"
        android:width="130px"
        android:layout_marginLeft="15dip"/>
    <Button
        android:id="@+id/trace"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/trace"
        android:width="130px"
        android:layout_alignBaseline="@id/locate"
        android:layout_alignParentRight="true"
        android:layout_marginRight="15dip"/>
</RelativeLayout>

</LinearLayout>
</ScrollView>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷情 2024-10-14 17:51:13

将地图移出 ScrollView。通常,您不能将可滚动的内容(例如 MapView)放入 ScrollView 中。

Move the map out of the ScrollView. Usually, you cannot put scrollable things, like MapView, in a ScrollView.

回梦 2024-10-14 17:51:13

迟到的答案,但我在谷歌搜索问题时发现了这篇文章,我还发现了另一个对我来说非常有效的答案: ScrollView 中的 MapView? 所以我想我也应该将其发布在这里。

Late late answer but I found this post while googling for the problem and I also found another answer that worked beautifully for me: MapView inside a ScrollView? so I thought I'd post it here as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文