Make Floatingactionbutton Overlay Linearlayout

Asked

Viewed 706 times

1

Hello,

I’m making a kind of Actionbar and precise with the Floatingactionbutton overlap the Linearlayout that is fixed at the bottom, it needs to be in the same position put on the front of the bar.

Follow image with the button below the Linearlayout:

inserir a descrição da imagem aqui

Follows xml code of the page:

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

2 answers

1

Pass the Floating Action Button code to before the

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

even at the end of the file, you must solve the problem, if not solve override the Elevation and put up 8dp

  • You could show me with an example?

  • I put the Button on the </android.support.v4.widget.Drawerlayout>, as he said, but apparently it only made the button stick to the top

0


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

inserir a descrição da imagem aqui

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.