0

I've implemented a custom compass and want to replace the default compass on a google map by mine. For that I've to put my rotating compass image in front ofthe google map. The problem is that my image is always put on the background and, so, hidden by the map. Here's the XML code.

Hope you could find a solution !

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="end"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<fragment
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_marginBottom="0dp"
    android:layout_marginTop="20dp" 
    android:gravity="bottom"/>

<TextView
    android:id="@+id/textDist"
    android:layout_width="286dp"
    android:layout_height="wrap_content"
    android:text="TextView" />

<ImageView
    android:id="@+id/imageCompass"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="5dp"
    android:layout_marginTop="25dp"
    android:src="@drawable/ic_compass"
    android:gravity="top" />

Thanks !

1 Answers1

0

You may play with z-order(this one or similar)

Be sure not to overlap Google logo as it's against Google's policies

Sam
  • 1,652
  • 17
  • 25
  • I already try the bringToFront() function but withtout success... I precise that I'll not hide the Google logo, it will stay visible, I just disable the googleMap Compass and now I want to put mine. – user2904864 Feb 10 '14 at 19:48
  • Check [this question](http://stackoverflow.com/questions/14694119/how-to-add-buttons-at-top-of-map-fragment-api-v2-layout): – Sam Feb 10 '14 at 19:50
  • Ok, I've tried again others things and it's very strange. Indeed, I can't see my own compass directly but if I run another app and go back to my app, I can see my compass appearing... It's so WTF. Any suggestions ? :/ – user2904864 Feb 10 '14 at 20:33
  • Ok guys, I start to fix the problem, it's due to the rotation of my compass, if I block it, a static image so, it works... The image seems to be sent to the back when it rotates. – user2904864 Feb 10 '14 at 21:38
  • If somebody had the same problem... It seems to be an android implementation bug but maybe a tips against that ? – user2904864 Feb 10 '14 at 22:26