How to make a View overlap?

Asked

Viewed 208 times

0

I have this XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context=".MapFragment">

<include
    android:id="@+id/include_toolbar_map"
    layout="@layout/toolbar_localizacao"
    />


<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_localizacao_24dp"
    android:theme="@style/FABTheme"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    android:layout_marginBottom="13dp"
    android:layout_marginEnd="13dp"
    />

<com.github.clans.fab.FloatingActionMenu
    android:id="@+id/fab_menu"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignEnd="@+id/fab"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="73dp">

</com.github.clans.fab.FloatingActionMenu>


<!-- TODO: Update blank fragment layout -->
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/map_fragment"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    tools:context=".MapActivity" />

inserir a descrição da imagem aqui

But it turns out that the fab_menu is behind the Fragment (as illustrated in the image), and my goal is to make it stand in front of the Fragment.

1 answer

0


You can use the Framelayout to make one view overlap another. Here’s an example of my video player:

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

    <FrameLayout
        android:id="@+id/framePlayer"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <SurfaceView
            android:id="@+id/svPlayer"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </FrameLayout>

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

        <android.support.v7.widget.Toolbar
            android:id="@+id/tbPlayer"
            android:background="@drawable/drop_shadow"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <ProgressBar
            android:id="@+id/playerSpinner"
            style="?android:progressBarStyleLarge"
            android:indeterminate="true"
            android:layout_gravity="center"
            android:visibility="gone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </FrameLayout>

</FrameLayout>

Browser other questions tagged

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