Skip to content Skip to sidebar Skip to footer

How To Create Overlay Layout In Android

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 wit

Solution 1:

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:

<FrameLayoutxmlns: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"><EditTextandroid:layout_width="fill_parent"android:id="@+id/editText1"android:layout_height="fill_parent"></EditText><EditTextandroid: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

Solution 2:

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

Solution 3:

<FrameLayoutxmlns: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" ><LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><!-- other actual layout stuff here  --></LinearLayout><LinearLayoutandroid: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

Post a Comment for "How To Create Overlay Layout In Android"