Как вывести FAB на верх макета - PullRequest
0 голосов
/ 26 сентября 2018

Я пытаюсь сделать 3 FAB между двумя представлениями.Но FAB находятся ниже вида сверху, как показано ниже.

Как мне вывести их на фронт?

enter image description here

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:clickable="true"
    android:focusableInTouchMode="true"
    android:id="@+id/parentPanel"
    android:background="#ffffff">

    <LinearLayout
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_weight="1">

        <android.support.v7.widget.CardView
            xmlns:card_view="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            card_view:cardCornerRadius="6dp"
            android:layout_margin="10dp"
            android:clickable="true"
            android:focusable="true"
            android:foreground="?android:selectableItemBackground"
            android:id="@+id/deviceCard">

            <fragment
                android:id="@+id/map"
                android:name="com.google.android.gms.maps.SupportMapFragment"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                tools:context="io.tegaru.beepr.AddNewMapsLocationActivity" />

        </android.support.v7.widget.CardView>

    </LinearLayout>

    <LinearLayout
        android:id="@+id/bottomPanel"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:layout_weight="4"
        android:background="@android:color/white">

        <LinearLayout
            android:id="@+id/btnPanel1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_weight="1"
            android:background="@android:color/white">

            <android.support.design.widget.FloatingActionButton
                android:id="@+id/fab1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:clickable="true"
                android:onClick="AddNewReminderBtnClicked"
                app:backgroundTint="#292929"
                app:fabSize="normal"
                app:srcCompat="@drawable/ic_menu_send"
                android:layout_gravity="top|center"
                android:layout_marginTop="-20dp" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/btnPanel2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_weight="1"
            android:background="@android:color/white">

            <android.support.design.widget.FloatingActionButton
                android:id="@+id/fab2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:clickable="true"
                android:onClick="AddNewReminderBtnClicked"
                app:backgroundTint="#292929"
                app:fabSize="normal"
                app:srcCompat="@drawable/ic_menu_send"
                android:layout_gravity="top|center"
                android:layout_marginTop="-20dp" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/btnPanel3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:layout_weight="1"
            android:background="@android:color/white">

            <android.support.design.widget.FloatingActionButton
                android:id="@+id/fab3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:clickable="true"
                android:onClick="AddNewReminderBtnClicked"
                app:backgroundTint="#292929"
                app:fabSize="normal"
                app:srcCompat="@drawable/ic_menu_send"
                android:layout_gravity="top|center"
                android:layout_marginTop="-20dp" />
        </LinearLayout>


    </LinearLayout>

</LinearLayout>

Ответы [ 2 ]

0 голосов
/ 26 сентября 2018

Чтобы равномерно распределить фабрики и использовать их в качестве наложения, например, для просмотра в Интернете, посмотрите мой код:

enter image description here

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:theme="@style/ThemeOverlay.AppCompat.Dark">

    <WebView
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"></WebView>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:clickable="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/fab2"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:clickable="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/fab3"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/fab1" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:clickable="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toEndOf="@+id/fab2" />

</android.support.constraint.ConstraintLayout>
0 голосов
/ 26 сентября 2018

LinearLayout не позволяет перекрывать дочерние представления.

Вы должны использовать RelativeLayout (или FrameLayout и т. Д.) Вместо LinearLayout в качестве родительского, если вы хотите отобразить FAB выше(перекрытие) других видов.

В вашем случае установите корневой макет на RelativeLayout.Возможно, вам придется внести другие корректировки.

...