2017-09-14 3 views
0

enter image description here OK J'ai donc créé fragment_googlemap.xml et j'ai conçu FrameLayout en tant que mise en page racine car j'avais besoin de mapView en tant que fragment. Coupé à la poursuite, ce que je voulais être arrivé est que pour montrer Spinner et Floating Action Button sur le dessus de google map. Mais quand je lance l'application, je ne peux pas voir les enfants de relativelayout (bouton spinner et flottant). Je pense que c'est sous googlemapview parce que je peux les voir sous googlemap pendant une seconde lors du chargement. Une solution pour cela?Mon Relativelayout ne s'affichera pas sous FrameLayout

ooohh et BTW Je ne sais pas pourquoi la valeur de l'attribut élévation bouton flottant ne fonctionne pas idée s'il vous plaît ????

Désolé si mon anglais est pauvre :(Et Thx à l'avance !!!

======= ici est mon code source de fichier XML ci-dessous ===========

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:fab="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    > 

    <Spinner 
     android:id="@+id/spinner_countries" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignRight="@+id/fab" 
     android:layout_below="@+id/fab" 
     android:entries="@array/location_arraysResc" /> 


    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentEnd="true" 
     android:layout_gravity="end|top" 
     android:layout_margin="10dp" 
     android:backgroundTint="@color/colorPrimary" 
     android:elevation="6dp" 
     android:src="@drawable/paperplane" 
     android:tint="#000000" 
     app:borderWidth="0dp" 
     app:rippleColor="#eF43ef" /> 
    </RelativeLayout> 


    <com.google.android.gms.maps.MapView 
     android:id="@+id/map" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 


    </com.google.android.gms.maps.MapView> 


</FrameLayout> 
+0

Mise en page Frame doit avoir seulement 1 enfant. Mettez votre mise en page relative et la carte dans une autre disposition avant de mettre en framelayout. – Lcukerd

+0

In Frame Layout Les vues enfant sont dessinées dans une pile, avec le dernier enfant ajouté en haut. Donc, dans votre cas, l'enfant récemment ajouté est mapview, c'est pourquoi votre spinner et votre bouton flottant sont derrière votre carte. Inversez l'ordre et tout ira bien. –

+0

quelle serait la meilleure mise en page? pour les mettre ensemble? – poream3387

Répondre

1

essayer cette

1.FloatingActionButton utilisation app:elevation="6dp" insted de android:elevation="6dp"

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <com.google.android.gms.maps.MapView 
     android:id="@+id/map" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

    </com.google.android.gms.maps.MapView> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentEnd="true" 
     android:layout_alignParentTop="true" 
     android:layout_margin="10dp" 
     android:backgroundTint="@color/colorPrimary" 
     android:elevation="6dp" 
     android:src="@drawable/ic_info_black_24dp" 
     android:tint="#000000" 
     app:borderWidth="0dp" 
     app:rippleColor="#eF43ef" /> 

    <Spinner 
     android:id="@+id/spinner_countries" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentEnd="true" 
     android:layout_alignRight="@+id/fab" 
     android:layout_below="@+id/fab" 
     android:entries="@array/myarray" /> 

</RelativeLayout> 
+0

si parent est un parent de correspondance, alors la carte ne s'affichera pas car l'orientation de la disposition linéaire est verticale et l'espace de l'écran est déjà couvert par la disposition relative. –

+0

serait Linearlayout mieux que FrameLayout dans ce cas ?? – poream3387

+0

@ poream3387 vérifier mis à jour ans –

1

vous pouvez penser à un FrameLayout comme LinearLayout, sauf qu'il empile des vues sur le dessus de l'autre. la dernière vue de la mise en page sera la vue de dessus à l'écran.

donc, si vous voulez mettre quelque chose sur votre MapView, vous devriez mettre ces balises de vue après l'étiquette <MapView>.

+0

TRAVAILLÉ THX !!!!!!!!!!!! – poream3387

0

Vous pouvez simplement mettre le MapView dans une nouvelle RelativeLayout, essayez ceci.

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:fab="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<RelativeLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    > 

    <Spinner 
     android:id="@+id/spinner_countries" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignRight="@+id/fab" 
     android:layout_below="@+id/fab" 
     android:entries="@array/location_arraysResc" /> 


    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentEnd="true" 
     android:layout_gravity="end|top" 
     android:layout_margin="10dp" 
     android:backgroundTint="@color/colorPrimary" 
     android:elevation="6dp" 
     android:src="@drawable/paperplane" 
     android:tint="#000000" 
     app:borderWidth="0dp" 
     app:rippleColor="#eF43ef" /> 
    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/spinner_countries" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 

     <com.google.android.gms.maps.MapView 
      android:id="@+id/map" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
     </com.google.android.gms.maps.MapView> 

    </RelativeLayout 

</FrameLayout> 
+1

vous devriez ajouter la carte le premier bouton, puis le bouton flottant en tant qu'enfant de la mise en page du cadre. Les vues enfant sont dessinées dans une pile, avec le dernier enfant ajouté en haut –

0

Essayez cette

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:fab="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

<com.google.android.gms.maps.MapView 
    android:id="@+id/map" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

</com.google.android.gms.maps.MapView> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <Spinner 
     android:id="@+id/spinner_countries" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignRight="@+id/fab" 
     android:layout_below="@+id/fab" 
     android:entries="@array/location_arraysResc" /> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentEnd="true" 
     android:layout_gravity="end|top" 
     android:layout_margin="10dp" 
     android:backgroundTint="@color/colorPrimary" 
     android:elevation="6dp" 
     android:src="@drawable/paperplane" 
     android:tint="#000000" 
     app:borderWidth="0dp" 
     app:rippleColor="#eF43ef" /> 
</RelativeLayout> 

+0

Thx pour votre opinion! – poream3387

+0

@ poream3387 Cela fonctionne bien comme prévu? ou tout problème –

+0

Il a travaillé THX !!!! :) pas de problème – poream3387