Reputation: 327
i want to make a view that will be below another view and overlays it too
i made the following
<RelativeLayout android:layout_height="wrap_content" android:layout_width="wrap_content">
<include layout="@layout/toolbar" android:id="@+id/tool"
/>
<include layout="@layout/content_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/tool"
android:layout_marginBottom="30dp"
/>
</RelativeLayout>
but it didn't work, any solutions?
Upvotes: 0
Views: 99
Reputation: 28179
First, you'll need to reverse the order of the views, toolbar
should hide content_main
so it should be added after it.
Second, you can use negative margins for this, you tell content_main
to be below toolbar
, and then put a negative top margin on it, so it moves a bit higher, and beneath toolbar
.
Example:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff0000" >
<TextView
android:text="first line, will be partially covered. fdjkfsjdf kldsjfkdsljfklds "
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"
android:layout_marginTop="-20dp"
android:textSize="36sp"
android:fontFamily="sans-serif-light"
android:background="#00ff00"/>
<TextView
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#0000ff"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textSize="36sp"
android:text="TOOLBAR" />
</RelativeLayout>
And result:
Upvotes: 1