Make FloatingActionButton overlap LinearLayout

1

Hello,

I'm doing a type of ActionBar and I need the FloatingActionButton to override the LinearLayout that is fixed at the bottom, it needs to stay in the same position however on the front of the bar.

Follow the image below the LinearLayout:

Followthexmlcodeofthepage:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorBackgroud"
    android:fitsSystemWindows="true"
    app:itemIconTint="@color/textColorPrimary"
    tools:openDrawer="start">

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

        <android.support.design.widget.FloatingActionButton
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:layout_marginBottom="30dp"
            android:layout_marginRight="20dp"
            android:backgroundTint="@color/colorPrimary"
            android:src="@drawable/ic_border_color"
            android:tint="@color/textColorSecondy" />

        <LinearLayout
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            tools:context=".activity.MainActivity">

            <include
                android:id="@+id/toolbar"
                layout="@layout/toolbar"
                android:layout_height="85dp"
                tools:ignore="IncludeLayoutParam" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:layout_alignParentBottom="true"
            android:background="@color/colorAccent"
            android:elevation="10dp"
            android:orientation="horizontal">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:orientation="horizontal">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="horizontal"
                    android:padding="10dp">

                    <ImageView
                        android:layout_width="22dp"
                        android:layout_height="match_parent"
                        android:src="@drawable/ic_message" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginLeft="12dp"
                        android:gravity="start"
                        android:text="Mensagens"
                        android:textColor="@color/textColorPrimary"
                        android:textSize="22sp" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="horizontal">

                    <ImageView
                        android:layout_width="22dp"
                        android:layout_height="match_parent"
                        android:src="@drawable/ic_bookmark" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginLeft="12dp"
                        android:gravity="start"
                        android:text="Itens salvos"
                        android:textColor="@color/textColorPrimary"
                        android:textSize="22sp" />
                </LinearLayout>

            </LinearLayout>

        </LinearLayout>

    </RelativeLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/navView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@color/colorBackgroud"
        app:headerLayout="@layout/nav_header"
        app:itemIconTint="@color/textColorPrimary"
        app:itemTextColor="@color/textColorPrimary"
        app:menu="@menu/menu_nav">

    </android.support.design.widget.NavigationView>

</android.support.v4.widget.DrawerLayout>
    
asked by anonymous 12.09.2018 / 12:38

2 answers

0

Follow the image of how it was and the code.   I put your 1st RelativeLayout inside another RelativeLayout

<?xmlversion="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 
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:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorBackgroud"
android:fitsSystemWindows="true"
app:itemIconTint="@color/textColorPrimary"
tools:openDrawer="start">

<RelativeLayout

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

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >
        <LinearLayout
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            tools:context=".activity.MainActivity">

            <include
                android:id="@+id/toolbar"
                layout="@layout/toolbar"
                android:layout_height="85dp"
                tools:ignore="IncludeLayoutParam" />

        </LinearLayout>


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:layout_alignParentBottom="true"
            android:background="@color/colorAccent"
            android:elevation="10dp"
            android:orientation="horizontal">


        <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:orientation="horizontal">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="horizontal"
                    android:padding="10dp">

                    <ImageView
                        android:layout_width="22dp"
                        android:layout_height="match_parent"
                        android:src="@drawable/ic_message" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_marginLeft="12dp"
                        android:gravity="start"
                        android:text="Mensagens"
                        android:textColor="@color/textColorPrimary"
                        android:textSize="22sp" />
                </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal">

                <ImageView
                    android:layout_width="22dp"
                    android:layout_height="match_parent"
                    android:src="@drawable/ic_bookmark" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginLeft="12dp"
                    android:gravity="start"
                    android:text="Itens salvos"
                    android:textColor="@color/textColorPrimary"
                    android:textSize="22sp" />
            </LinearLayout>

            </LinearLayout>

        </LinearLayout>


    </RelativeLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_marginBottom="30dp"
        android:layout_marginRight="20dp"
        android:backgroundTint="@color/colorPrimary"
        android:src="@drawable/ic_border_color"
        android:tint="@color/textColorSecondy" />

</RelativeLayout>

<android.support.design.widget.NavigationView
    android:id="@+id/navView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="@color/colorBackgroud"
    app:headerLayout="@layout/nav_header"
    app:itemIconTint="@color/textColorPrimary"
    app:itemTextColor="@color/textColorPrimary"
    app:menu="@menu/menu_nav">

</android.support.design.widget.NavigationView>

    
12.09.2018 / 15:38
0

Pass the Floating Action Button code to before

</android.support.v4.widget.DrawerLayout>

Even at the end of the file, you should solve the problem, if it does not resolve the elevation override and put it above 8dp

    
12.09.2018 / 14:44