Floats so that they do not take up space in the layout

Is it possible to float elements over other Android elements so that they do not affect the location of their container?

The effect I want to achieve is a speech-like floating element:

enter image description here

The yellow square above is the element that I want to swim above the other elements, but as you can see, it pushes its container down, creating a black space under the green stripe, instead of floating above the gray area below it.

RelativeLayout can position the element accordingly, but I cannot find a way to make the located element not extend the border of its container. Is this possible on Android?


ANALOGUES

  • in the web world, an equivalent is an element that has a “position: absolute” and therefore is not considered part of the “stream” (i.e.: layout)
  • WPF , Canvas. Canvas , , .
  • iOS ( ), x y .
+5
2

RelativeLayout , .

.

:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <Button
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:text="@string/big"
        android:textSize="120dip"
        android:textStyle="bold"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="@string/small"/>

</RelativeLayout>

Floating buttons

. " ", , .

RelativeLayout ( FrameLayout), , . . , , .

, " " , Gmail:

Floating Undo Bar

+10

Relative layouts android: , , .

http://developer.android.com/guide/topics/ui/layout/relative.html

:

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

    <TextView
        android:id="@+id/update"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:background="#444444"
        android:text="Update"
        android:textAppearance="?android:attr/textAppearanceLarge" />


    <TextView
        android:id="@+id/lost_of_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/some_button"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:text="text view with lots of text"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <Button
        android:id="@+id/some_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:text="Some Button" />

</RelativeLayout>

: CommonsWare ;) !

+1

All Articles