Reputation: 218
I am trying to place two layouts on top of each other. I am using relative layouts and placing them inside a relative layout. But the problem is I am only getting one of the layouts displayed and that is the latter one.
Here is my code:
<?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="wrap_content"
android:layout_height="match_parent"
android:gravity="bottom|center"
android:orientation="vertical"
android:weightSum="1"
tools:context=".MainActivity" >
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:background="#00ACE7"
android:orientation="vertical"
android:weightSum="1" >
<ImageView
android:id="@+id/telenor_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/telenor_logo"
android:src="@drawable/telenor_logo" />
<ImageView
android:id="@+id/telenor_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/telenor_logo" />
<ImageButton
android:id="@+id/options"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginRight="50dp"
android:background="#00ACE7"
android:src="@drawable/options" />
<ImageButton
android:id="@+id/settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#00ACE7"
android:src="@drawable/settings" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativelayout2"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:background="#B6B6B4"
android:visibility="visible"
android:weightSum="1"
android:layout_below="@+android:id/relative_layout1" >
</RelativeLayout>
</RelativeLayout>
Upvotes: 0
Views: 1622
Reputation: 9225
Please change this android:layout_below="@+android:id/relative_layout1"
with android:layout_below="@+id/relativeLayout1"
to set relativleayout1 on top of relativelayout2
Upvotes: 0
Reputation: 589
Change this attribute to the following in the second relative layout
android:layout_below="@id/relativeLayout1"
So it would end up looking like this
<RelativeLayout
android:id="@+id/relativelayout2"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:background="#B6B6B4"
android:visibility="visible"
android:weightSum="1"
android:layout_below="@id/relativeLayout1">
</RelativeLayout>
Also, just as a quick note:
android:layout_width="fill_parent"
(in API Level 8+) should be replaced by:
android:layout_width="match_parent"
Upvotes: 3