Мой Relativelayout не будет отображаться в FrameLayout

введите описание изображения здесь OK Итак, я создал фрагмент_googlemap.xml и разработал FrameLayout в качестве корневого макета, потому что мне нужно было использовать mapView в качестве фрагмента. Перейдем к преследованию. То, что я хотел, чтобы это произошло, - это показать Spinner и Floating Action Button в верхней части карты Google. Но когда я запускаю приложение, я не вижу дочерние элементы родственника (вращающийся и плавающий кнопки). Я думаю, что это в googlemapview, потому что я могу видеть их в googlemap на секунду при загрузке. Любое решение для этого?

OOOHH и Кстати, я не знаю, почему значение атрибута высоты в плавающей кнопке не работает идея, пожалуйста????

Извините, если мой английский плохой:(И спасибо заранее!!!

======= вот мой исходный код xml файла ниже ===========

<?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> 

4 ответа

Решение

Попробуй это

1. FloatingActionButton использование app:elevation="6dp" поставленный 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>

Вы можете думать о FrameLayout как LinearLayout, за исключением того, что складывает взгляды друг на друга. Последним видом в макете будет вид сверху на экране.

Так что если вы хотите положить что-то поверх вашего MapView, вы должны поставить эти теги просмотра после <MapView> тег.

Вы можете просто поставить MapView внутри нового RelativeLayout, попробуй это.

<?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> 

Попробуй это

<?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>

Другие вопросы по тегам