Bonjour

J'ai dans une activité une MapView dans un scrollView. Devant le problème de la transmission de l’événement OnTouch j'ai surchargé cette fonction le MapView comme j'ai pu le voir sur internet:

CustomMapView :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
public class CustomMapView extends MapView {
 
	public ScrollView scroll;
 
	public CustomMapView(Context context, AttributeSet attrs) {
		super(context, attrs);
 
		this.setSatellite(true);
		this.setStreetView(false);
		this.setTraffic(false);
		this.setBuiltInZoomControls(true);
 
	}
 
	@Override
	public boolean onTouchEvent(MotionEvent ev) {
		int action = ev.getAction();
		switch (action) {
		case MotionEvent.ACTION_DOWN:
			// Disallow ScrollView to intercept touch events.
			scroll.requestDisallowInterceptTouchEvent(true);
			break;
 
		case MotionEvent.ACTION_UP:
			// Allow ScrollView to intercept touch events.
			scroll.requestDisallowInterceptTouchEvent(false);
			break;
		}
		// Handle MapView's touch events.
		super.onTouchEvent(ev);
 
		return true;
	}
}
Cela fonctionne mais sur certain portable le zoom avec le double touche fonctionne et d'autre non.
J'ai essayer sur un Sony Ericsson Xperia Arc, le zoom fonctionne mais sur deux HTC il ne fonctionne pas (Wildfire et Desire). Les version de google map sont identique et les HTC sont en android 2.2 alors que le Sony Ericsson est en 2.3.4.

Je ne peux pas remplacer le zoom au doigt par les bouton car ils prendrait trop de place.

Gabarit XML :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RootView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    android:focusableInTouchMode="true" >
 
    <ScrollView
        android:id="@+id/scroll"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@id/Header" >
 
        <LinearLayout
            android:id="@+id/Body"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical|center_horizontal"
            android:orientation="vertical" >
 
          [...]
 
            <RelativeLayout
                android:id="@+id/tabContainer"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" >
 
                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="@dimen/listPlace_Height"
                    android:layout_below="@id/tabButtons_Container" >
 
                        <RelativeLayout
                            android:id="@+id/map_Container"
                            android:layout_width="fill_parent"
                            android:layout_height="match_parent"
                            android:background="#000000" >
 
                            <AbsoluteLayout
                                android:layout_width="fill_parent"
                                android:layout_height="match_parent" >
 
                                <"Package".CustomMapView
                                    android:id="@+id/mapView"
                                    android:layout_width="fill_parent"
                                    android:layout_height="match_parent"
                                    android:apiKey="@string/APIKey"
                                    android:clickable="true"
                                    android:enabled="true"/>
                            </AbsoluteLayout>
                        </RelativeLayout>
 
						[...]
                </LinearLayout>
            </RelativeLayout>
 
        </LinearLayout>
    </ScrollView>
 
</RelativeLayout>
Merci a tous