0

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>
NullPointerException
  • 36,107
  • 79
  • 222
  • 382

2 Answers2

1

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

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • @AndroidUser99: Redesign your UI so you do not need the map on the `ScrollView`. Or, set `android:clickable="false"` on the `MapView` so the `MapView` cannot be manipulated directly by the user -- this *might* allow it to work in a `ScrollView`. – CommonsWare Dec 17 '10 at 15:53
0

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.

Community
  • 1
  • 1
Fluff
  • 548
  • 4
  • 8