2010-12-15 5 views
0

Ich habe ein Scrollview-Layout, mit einigen Textansichten und Schaltflächen und auch eine Mapview in der Mitte. Alle Inhalte von Dieses Layout befindet sich in einer Scrollansicht, da es viele Dinge hat und Benutzer die Fenster scrollen müssen, um alle zu sehen.Probleme mit einem Scrollview-Layout mit etwas Text und einem Mapview darauf ... Ich kann die Karte nicht verschieben

Aber dann habe ich ein Problem, wenn der Benutzer versucht, die Karte zu verschieben, es bewegt sich nicht, und der Finger scrollt das gesamte Fenster, wegen der Scrollview. Es ist cool, die Möglichkeit zu haben, das gesamte Fenster zu scrollen, aber ich möchte, dass wenn der Benutzer den Finger auf der Karte bewegt, der Benutzer nur die Karte scrollt.

gibt es eine Möglichkeit, dieses Problem zu beheben, ohne die Scrollview zu entfernen? ich brauche es!

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

Antwort

1

Verschieben Sie die Karte aus dem ScrollView. Normalerweise können Sie keine scrollbaren Objekte wie in eine ScrollView einfügen.

+0

Ich brauche die Karte auf der Bildlaufansicht ... – NullPointerException

+0

@ AndroidUser99: Redesign Ihre Benutzeroberfläche, so dass Sie nicht die Karte auf der 'ScrollView' benötigen. Oder setzen Sie 'android: clickable =" false "' auf der 'MapView', so dass die' MapView' nicht direkt vom Benutzer manipuliert werden kann - dies * erlaubt es * möglicherweise, in einer 'ScrollView' zu arbeiten. – CommonsWare

0

Spät späte Antwort, aber ich fand diesen Beitrag beim googeln für das Problem, und ich fand auch eine andere Antwort, die schön für mich funktionierte: MapView inside a ScrollView?, also dachte ich, ich würde es auch hier posten.

Verwandte Themen