0

How can i create the layout like i attached in the background as normal any layout.From that layout when i click any or get back to that layout, the overlay layout should come with any form fields buttons or text ...any

Thanks in advance.

enter image description here

Sanket Pandya
  • 1,095
  • 7
  • 21
Subha
  • 741
  • 2
  • 9
  • 23
  • You want to interchange the layouts visibility or what is your ultimate goal? – g00dy Mar 15 '13 at 11:24
  • What i mean., in the layout bottom Airtel text.Ff i touch that, The number layout wants to up.Again clcik the same number layout need to down to hide. something like android keybowrd display (if click textbox the android keybord will slide up same effect) – Subha Mar 18 '13 at 08:08
  • Possible duplicate of [Android overlay a view ontop of everything?](http://stackoverflow.com/questions/7519160/android-overlay-a-view-ontop-of-everything) – Arpit Patel Oct 02 '16 at 19:13

3 Answers3

4

Use RelativeLayout or FrameLayout. The last child view will overlay everything else.

To be sure the overlay view is on top, you can call ViewGroup.bringChildViewToFront() on the relative layout.

Example:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/root_view">

    <EditText
        android:layout_width="fill_parent"
        android:id="@+id/editText1"
        android:layout_height="fill_parent">
    </EditText>

    <EditText
        android:layout_width="fill_parent"
        android:id="@+id/editText2"
        android:layout_height="fill_parent">
        <requestFocus></requestFocus>
    </EditText>

</FrameLayout>

In this layout, editText2 will cover the editText1

Jainendra
  • 24,713
  • 30
  • 122
  • 169
  • Please refer to this question http://stackoverflow.com/questions/7519160/android-overlay-a-view-ontop-of-everything. – Recomer Mar 30 '16 at 12:01
1

I believe you should use FrameLayout, you can add objects one in front of the other. Please read about it at documentation.

Marko Niciforovic
  • 3,561
  • 2
  • 21
  • 28
0
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/root_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

        <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
        <!-- other actual layout stuff here  -->

       </LinearLayout>

    <LinearLayout
    android:id="@+id/overlay"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="right" >
    </LinearLayout>

    </FrameLayout>

Now any view you add under LinearLayout with android:id = "@+id/overlay" will appear as overlay with gravity = right

hopefully this will help you

Dilroop Singh
  • 544
  • 6
  • 16