Reputation: 107
i'm looking for a way to display an "overlay" view across multiple layouts (As scribbled in the attached image).
My research showed that layouts can only live inside other layouts and that there is no such concept of overlay layout. Is that possible? Any suggestions?
Many thanks! Kay.
Upvotes: 0
Views: 759
Reputation: 1046
FrameLayout is the only layout that kan render overlapping Views
<?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" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Primary View Primary View Primary View Primary View" />
</LinearLayout>
<RelativeLayout
android:layout_width="100dp"
android:layout_height="match_parent"
android:background="#80FFFFFF" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="OverLap" />
</RelativeLayout>
</FrameLayout>
Upvotes: 1
Reputation: 893
I guess you need to show a view or layout element over layout. in case you should use FrameLayout like this
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
Your layout
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
Your view element to float or overlay
</LinearLayout>
</FrameLayout>
Upvotes: 0