RelativeLayout background overlap availability
I have a 9-patch drawable (date_time). And I want to position this resource over the content of the Relative Layout, so all child views should be drawn on top of this image. Here is the xml Layout:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="23dp"
android:layout_below="@id/tv_map_address"
android:layout_marginTop="11dp"
android:layout_marginBottom="12dp"
android:background="@drawable/date_time">
<ImageView
android:id="@+id/iv_map_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_centerVertical="true"
android:src="@drawable/ic_map_distance"/>
<TextView
android:id="@+id/tv_map_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/iv_map_distance"
android:layout_centerVertical="true"
android:textColor="@color/white"
android:textSize="11sp"
android:text="2,7 "
fontPath="fonts/Roboto-Medium.ttf"/>
<ImageView
android:id="@+id/iv_map_path"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/tv_map_distance"
android:layout_centerVertical="true"
android:src="@drawable/ic_map_path"/>
<TextView
android:id="@+id/tv_map_path"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_toRightOf="@id/iv_map_path"
android:layout_centerVertical="true"
android:textColor="@color/white"
android:textSize="11sp"
android:text="3,2 "
fontPath="fonts/Roboto-Medium.ttf"/>
</RelativeLayout>
But somehow this background overlaps all child content. This shows what's going on.
But if I replace
android:background="@drawable/date_time"
to
android:background="#0000FF"
Everything is fine and the result is as follows:
Can you explain to me what I am doing wrong?
Update: Here is my version with 9 patches.
source to share
Exactly as I thought your content indicators are wrong (unless you want to introduce such an addition to your 9 patch). Try this instead:
Right and Bottom Guides, determine how much (or how much) of yours drawable
should be taken up by your content. You set this area to a really small space and set a fixed height to yours Layout
. In other words: 9-patch made yours only Layout
allow your kids to occupy a small area of your view (which was limited by you, not allowing yours to stretch Layout
).
source to share